
kernel/kernel:     file format elf64-littleriscv


Disassembly of section .text:

0000000080000000 <_entry>:
    80000000:	00009117          	auipc	sp,0x9
    80000004:	80013103          	ld	sp,-2048(sp) # 80008800 <_GLOBAL_OFFSET_TABLE_+0x8>
    80000008:	6505                	lui	a0,0x1
    8000000a:	f14025f3          	csrr	a1,mhartid
    8000000e:	0585                	addi	a1,a1,1
    80000010:	02b50533          	mul	a0,a0,a1
    80000014:	912a                	add	sp,sp,a0
    80000016:	072000ef          	jal	ra,80000088 <start>

000000008000001a <spin>:
    8000001a:	a001                	j	8000001a <spin>

000000008000001c <timerinit>:
// which arrive at timervec in kernelvec.S,
// which turns them into software interrupts for
// devintr() in trap.c.
void
timerinit()
{
    8000001c:	1141                	addi	sp,sp,-16
    8000001e:	e422                	sd	s0,8(sp)
    80000020:	0800                	addi	s0,sp,16
// which hart (core) is this?
static inline uint64
r_mhartid()
{
  uint64 x;
  asm volatile("csrr %0, mhartid" : "=r" (x) );
    80000022:	f14027f3          	csrr	a5,mhartid
  // each CPU has a separate source of timer interrupts.
  int id = r_mhartid();
    80000026:	2781                	sext.w	a5,a5

  // ask the CLINT for a timer interrupt.
  int interval = 1000000; // cycles; about 1/10th second in qemu.
  *(uint64*)CLINT_MTIMECMP(id) = *(uint64*)CLINT_MTIME + interval;
    80000028:	0037969b          	slliw	a3,a5,0x3
    8000002c:	02004737          	lui	a4,0x2004
    80000030:	96ba                	add	a3,a3,a4
    80000032:	0200c737          	lui	a4,0x200c
    80000036:	ff873603          	ld	a2,-8(a4) # 200bff8 <_entry-0x7dff4008>
    8000003a:	000f4737          	lui	a4,0xf4
    8000003e:	24070713          	addi	a4,a4,576 # f4240 <_entry-0x7ff0bdc0>
    80000042:	963a                	add	a2,a2,a4
    80000044:	e290                	sd	a2,0(a3)

  // prepare information in scratch[] for timervec.
  // scratch[0..3] : space for timervec to save registers.
  // scratch[4] : address of CLINT MTIMECMP register.
  // scratch[5] : desired interval (in cycles) between timer interrupts.
  uint64 *scratch = &mscratch0[32 * id];
    80000046:	0057979b          	slliw	a5,a5,0x5
    8000004a:	078e                	slli	a5,a5,0x3
    8000004c:	00009617          	auipc	a2,0x9
    80000050:	fe460613          	addi	a2,a2,-28 # 80009030 <mscratch0>
    80000054:	97b2                	add	a5,a5,a2
  scratch[4] = CLINT_MTIMECMP(id);
    80000056:	f394                	sd	a3,32(a5)
  scratch[5] = interval;
    80000058:	f798                	sd	a4,40(a5)
}

static inline void 
w_mscratch(uint64 x)
{
  asm volatile("csrw mscratch, %0" : : "r" (x));
    8000005a:	34079073          	csrw	mscratch,a5
  asm volatile("csrw mtvec, %0" : : "r" (x));
    8000005e:	00006797          	auipc	a5,0x6
    80000062:	d8278793          	addi	a5,a5,-638 # 80005de0 <timervec>
    80000066:	30579073          	csrw	mtvec,a5
  asm volatile("csrr %0, mstatus" : "=r" (x) );
    8000006a:	300027f3          	csrr	a5,mstatus

  // set the machine-mode trap handler.
  w_mtvec((uint64)timervec);

  // enable machine-mode interrupts.
  w_mstatus(r_mstatus() | MSTATUS_MIE);
    8000006e:	0087e793          	ori	a5,a5,8
  asm volatile("csrw mstatus, %0" : : "r" (x));
    80000072:	30079073          	csrw	mstatus,a5
  asm volatile("csrr %0, mie" : "=r" (x) );
    80000076:	304027f3          	csrr	a5,mie

  // enable machine-mode timer interrupts.
  w_mie(r_mie() | MIE_MTIE);
    8000007a:	0807e793          	ori	a5,a5,128
  asm volatile("csrw mie, %0" : : "r" (x));
    8000007e:	30479073          	csrw	mie,a5
}
    80000082:	6422                	ld	s0,8(sp)
    80000084:	0141                	addi	sp,sp,16
    80000086:	8082                	ret

0000000080000088 <start>:
{
    80000088:	1141                	addi	sp,sp,-16
    8000008a:	e406                	sd	ra,8(sp)
    8000008c:	e022                	sd	s0,0(sp)
    8000008e:	0800                	addi	s0,sp,16
  asm volatile("csrr %0, mstatus" : "=r" (x) );
    80000090:	300027f3          	csrr	a5,mstatus
  x &= ~MSTATUS_MPP_MASK;
    80000094:	7779                	lui	a4,0xffffe
    80000096:	7ff70713          	addi	a4,a4,2047 # ffffffffffffe7ff <end+0xffffffff7ffd87ff>
    8000009a:	8ff9                	and	a5,a5,a4
  x |= MSTATUS_MPP_S;
    8000009c:	6705                	lui	a4,0x1
    8000009e:	80070713          	addi	a4,a4,-2048 # 800 <_entry-0x7ffff800>
    800000a2:	8fd9                	or	a5,a5,a4
  asm volatile("csrw mstatus, %0" : : "r" (x));
    800000a4:	30079073          	csrw	mstatus,a5
  asm volatile("csrw mepc, %0" : : "r" (x));
    800000a8:	00001797          	auipc	a5,0x1
    800000ac:	e8a78793          	addi	a5,a5,-374 # 80000f32 <main>
    800000b0:	34179073          	csrw	mepc,a5
  asm volatile("csrw satp, %0" : : "r" (x));
    800000b4:	4781                	li	a5,0
    800000b6:	18079073          	csrw	satp,a5
  asm volatile("csrw medeleg, %0" : : "r" (x));
    800000ba:	67c1                	lui	a5,0x10
    800000bc:	17fd                	addi	a5,a5,-1
    800000be:	30279073          	csrw	medeleg,a5
  asm volatile("csrw mideleg, %0" : : "r" (x));
    800000c2:	30379073          	csrw	mideleg,a5
  asm volatile("csrr %0, sie" : "=r" (x) );
    800000c6:	104027f3          	csrr	a5,sie
  w_sie(r_sie() | SIE_SEIE | SIE_STIE | SIE_SSIE);
    800000ca:	2227e793          	ori	a5,a5,546
  asm volatile("csrw sie, %0" : : "r" (x));
    800000ce:	10479073          	csrw	sie,a5
  timerinit();
    800000d2:	00000097          	auipc	ra,0x0
    800000d6:	f4a080e7          	jalr	-182(ra) # 8000001c <timerinit>
  asm volatile("csrr %0, mhartid" : "=r" (x) );
    800000da:	f14027f3          	csrr	a5,mhartid
  w_tp(id);
    800000de:	2781                	sext.w	a5,a5
}

static inline void 
w_tp(uint64 x)
{
  asm volatile("mv tp, %0" : : "r" (x));
    800000e0:	823e                	mv	tp,a5
  asm volatile("mret");
    800000e2:	30200073          	mret
}
    800000e6:	60a2                	ld	ra,8(sp)
    800000e8:	6402                	ld	s0,0(sp)
    800000ea:	0141                	addi	sp,sp,16
    800000ec:	8082                	ret

00000000800000ee <consolewrite>:
//
// user write()s to the console go here.
//
int
consolewrite(int user_src, uint64 src, int n)
{
    800000ee:	715d                	addi	sp,sp,-80
    800000f0:	e486                	sd	ra,72(sp)
    800000f2:	e0a2                	sd	s0,64(sp)
    800000f4:	fc26                	sd	s1,56(sp)
    800000f6:	f84a                	sd	s2,48(sp)
    800000f8:	f44e                	sd	s3,40(sp)
    800000fa:	f052                	sd	s4,32(sp)
    800000fc:	ec56                	sd	s5,24(sp)
    800000fe:	0880                	addi	s0,sp,80
    80000100:	8a2a                	mv	s4,a0
    80000102:	892e                	mv	s2,a1
    80000104:	89b2                	mv	s3,a2
  int i;

  acquire(&cons.lock);
    80000106:	00011517          	auipc	a0,0x11
    8000010a:	72a50513          	addi	a0,a0,1834 # 80011830 <cons>
    8000010e:	00001097          	auipc	ra,0x1
    80000112:	b54080e7          	jalr	-1196(ra) # 80000c62 <acquire>
  for(i = 0; i < n; i++){
    80000116:	05305b63          	blez	s3,8000016c <consolewrite+0x7e>
    8000011a:	4481                	li	s1,0
    char c;
    if(either_copyin(&c, user_src, src+i, 1) == -1)
    8000011c:	5afd                	li	s5,-1
    8000011e:	4685                	li	a3,1
    80000120:	864a                	mv	a2,s2
    80000122:	85d2                	mv	a1,s4
    80000124:	fbf40513          	addi	a0,s0,-65
    80000128:	00002097          	auipc	ra,0x2
    8000012c:	442080e7          	jalr	1090(ra) # 8000256a <either_copyin>
    80000130:	01550c63          	beq	a0,s5,80000148 <consolewrite+0x5a>
      break;
    uartputc(c);
    80000134:	fbf44503          	lbu	a0,-65(s0)
    80000138:	00000097          	auipc	ra,0x0
    8000013c:	7ee080e7          	jalr	2030(ra) # 80000926 <uartputc>
  for(i = 0; i < n; i++){
    80000140:	2485                	addiw	s1,s1,1
    80000142:	0905                	addi	s2,s2,1
    80000144:	fc999de3          	bne	s3,s1,8000011e <consolewrite+0x30>
  }
  release(&cons.lock);
    80000148:	00011517          	auipc	a0,0x11
    8000014c:	6e850513          	addi	a0,a0,1768 # 80011830 <cons>
    80000150:	00001097          	auipc	ra,0x1
    80000154:	bc6080e7          	jalr	-1082(ra) # 80000d16 <release>

  return i;
}
    80000158:	8526                	mv	a0,s1
    8000015a:	60a6                	ld	ra,72(sp)
    8000015c:	6406                	ld	s0,64(sp)
    8000015e:	74e2                	ld	s1,56(sp)
    80000160:	7942                	ld	s2,48(sp)
    80000162:	79a2                	ld	s3,40(sp)
    80000164:	7a02                	ld	s4,32(sp)
    80000166:	6ae2                	ld	s5,24(sp)
    80000168:	6161                	addi	sp,sp,80
    8000016a:	8082                	ret
  for(i = 0; i < n; i++){
    8000016c:	4481                	li	s1,0
    8000016e:	bfe9                	j	80000148 <consolewrite+0x5a>

0000000080000170 <consoleread>:
// user_dist indicates whether dst is a user
// or kernel address.
//
int
consoleread(int user_dst, uint64 dst, int n)
{
    80000170:	7119                	addi	sp,sp,-128
    80000172:	fc86                	sd	ra,120(sp)
    80000174:	f8a2                	sd	s0,112(sp)
    80000176:	f4a6                	sd	s1,104(sp)
    80000178:	f0ca                	sd	s2,96(sp)
    8000017a:	ecce                	sd	s3,88(sp)
    8000017c:	e8d2                	sd	s4,80(sp)
    8000017e:	e4d6                	sd	s5,72(sp)
    80000180:	e0da                	sd	s6,64(sp)
    80000182:	fc5e                	sd	s7,56(sp)
    80000184:	f862                	sd	s8,48(sp)
    80000186:	f466                	sd	s9,40(sp)
    80000188:	f06a                	sd	s10,32(sp)
    8000018a:	ec6e                	sd	s11,24(sp)
    8000018c:	0100                	addi	s0,sp,128
    8000018e:	8caa                	mv	s9,a0
    80000190:	8aae                	mv	s5,a1
    80000192:	8a32                	mv	s4,a2
  uint target;
  int c;
  char cbuf;

  target = n;
    80000194:	00060b1b          	sext.w	s6,a2
  acquire(&cons.lock);
    80000198:	00011517          	auipc	a0,0x11
    8000019c:	69850513          	addi	a0,a0,1688 # 80011830 <cons>
    800001a0:	00001097          	auipc	ra,0x1
    800001a4:	ac2080e7          	jalr	-1342(ra) # 80000c62 <acquire>
  while(n > 0){
    800001a8:	09405663          	blez	s4,80000234 <consoleread+0xc4>
    // wait until interrupt handler has put some
    // input into cons.buffer.
    while(cons.r == cons.w){
    800001ac:	00011497          	auipc	s1,0x11
    800001b0:	68448493          	addi	s1,s1,1668 # 80011830 <cons>
      if(myproc()->killed){
        release(&cons.lock);
        return -1;
      }
      sleep(&cons.r, &cons.lock);
    800001b4:	89a6                	mv	s3,s1
    800001b6:	00011917          	auipc	s2,0x11
    800001ba:	71290913          	addi	s2,s2,1810 # 800118c8 <cons+0x98>
    }

    c = cons.buf[cons.r++ % INPUT_BUF];

    if(c == C('D')){  // end-of-file
    800001be:	4c11                	li	s8,4
      break;
    }

    // copy the input byte to the user-space buffer.
    cbuf = c;
    if(either_copyout(user_dst, dst, &cbuf, 1) == -1)
    800001c0:	5d7d                	li	s10,-1
      break;

    dst++;
    --n;

    if(c == '\n'){
    800001c2:	4da9                	li	s11,10
    while(cons.r == cons.w){
    800001c4:	0984a783          	lw	a5,152(s1)
    800001c8:	09c4a703          	lw	a4,156(s1)
    800001cc:	02f71463          	bne	a4,a5,800001f4 <consoleread+0x84>
      if(myproc()->killed){
    800001d0:	00002097          	auipc	ra,0x2
    800001d4:	8c8080e7          	jalr	-1848(ra) # 80001a98 <myproc>
    800001d8:	591c                	lw	a5,48(a0)
    800001da:	eba5                	bnez	a5,8000024a <consoleread+0xda>
      sleep(&cons.r, &cons.lock);
    800001dc:	85ce                	mv	a1,s3
    800001de:	854a                	mv	a0,s2
    800001e0:	00002097          	auipc	ra,0x2
    800001e4:	0d2080e7          	jalr	210(ra) # 800022b2 <sleep>
    while(cons.r == cons.w){
    800001e8:	0984a783          	lw	a5,152(s1)
    800001ec:	09c4a703          	lw	a4,156(s1)
    800001f0:	fef700e3          	beq	a4,a5,800001d0 <consoleread+0x60>
    c = cons.buf[cons.r++ % INPUT_BUF];
    800001f4:	0017871b          	addiw	a4,a5,1
    800001f8:	08e4ac23          	sw	a4,152(s1)
    800001fc:	07f7f713          	andi	a4,a5,127
    80000200:	9726                	add	a4,a4,s1
    80000202:	01874703          	lbu	a4,24(a4)
    80000206:	00070b9b          	sext.w	s7,a4
    if(c == C('D')){  // end-of-file
    8000020a:	078b8863          	beq	s7,s8,8000027a <consoleread+0x10a>
    cbuf = c;
    8000020e:	f8e407a3          	sb	a4,-113(s0)
    if(either_copyout(user_dst, dst, &cbuf, 1) == -1)
    80000212:	4685                	li	a3,1
    80000214:	f8f40613          	addi	a2,s0,-113
    80000218:	85d6                	mv	a1,s5
    8000021a:	8566                	mv	a0,s9
    8000021c:	00002097          	auipc	ra,0x2
    80000220:	2f8080e7          	jalr	760(ra) # 80002514 <either_copyout>
    80000224:	01a50863          	beq	a0,s10,80000234 <consoleread+0xc4>
    dst++;
    80000228:	0a85                	addi	s5,s5,1
    --n;
    8000022a:	3a7d                	addiw	s4,s4,-1
    if(c == '\n'){
    8000022c:	01bb8463          	beq	s7,s11,80000234 <consoleread+0xc4>
  while(n > 0){
    80000230:	f80a1ae3          	bnez	s4,800001c4 <consoleread+0x54>
      // a whole line has arrived, return to
      // the user-level read().
      break;
    }
  }
  release(&cons.lock);
    80000234:	00011517          	auipc	a0,0x11
    80000238:	5fc50513          	addi	a0,a0,1532 # 80011830 <cons>
    8000023c:	00001097          	auipc	ra,0x1
    80000240:	ada080e7          	jalr	-1318(ra) # 80000d16 <release>

  return target - n;
    80000244:	414b053b          	subw	a0,s6,s4
    80000248:	a811                	j	8000025c <consoleread+0xec>
        release(&cons.lock);
    8000024a:	00011517          	auipc	a0,0x11
    8000024e:	5e650513          	addi	a0,a0,1510 # 80011830 <cons>
    80000252:	00001097          	auipc	ra,0x1
    80000256:	ac4080e7          	jalr	-1340(ra) # 80000d16 <release>
        return -1;
    8000025a:	557d                	li	a0,-1
}
    8000025c:	70e6                	ld	ra,120(sp)
    8000025e:	7446                	ld	s0,112(sp)
    80000260:	74a6                	ld	s1,104(sp)
    80000262:	7906                	ld	s2,96(sp)
    80000264:	69e6                	ld	s3,88(sp)
    80000266:	6a46                	ld	s4,80(sp)
    80000268:	6aa6                	ld	s5,72(sp)
    8000026a:	6b06                	ld	s6,64(sp)
    8000026c:	7be2                	ld	s7,56(sp)
    8000026e:	7c42                	ld	s8,48(sp)
    80000270:	7ca2                	ld	s9,40(sp)
    80000272:	7d02                	ld	s10,32(sp)
    80000274:	6de2                	ld	s11,24(sp)
    80000276:	6109                	addi	sp,sp,128
    80000278:	8082                	ret
      if(n < target){
    8000027a:	000a071b          	sext.w	a4,s4
    8000027e:	fb677be3          	bleu	s6,a4,80000234 <consoleread+0xc4>
        cons.r--;
    80000282:	00011717          	auipc	a4,0x11
    80000286:	64f72323          	sw	a5,1606(a4) # 800118c8 <cons+0x98>
    8000028a:	b76d                	j	80000234 <consoleread+0xc4>

000000008000028c <consputc>:
{
    8000028c:	1141                	addi	sp,sp,-16
    8000028e:	e406                	sd	ra,8(sp)
    80000290:	e022                	sd	s0,0(sp)
    80000292:	0800                	addi	s0,sp,16
  if(c == BACKSPACE){
    80000294:	10000793          	li	a5,256
    80000298:	00f50a63          	beq	a0,a5,800002ac <consputc+0x20>
    uartputc_sync(c);
    8000029c:	00000097          	auipc	ra,0x0
    800002a0:	58a080e7          	jalr	1418(ra) # 80000826 <uartputc_sync>
}
    800002a4:	60a2                	ld	ra,8(sp)
    800002a6:	6402                	ld	s0,0(sp)
    800002a8:	0141                	addi	sp,sp,16
    800002aa:	8082                	ret
    uartputc_sync('\b'); uartputc_sync(' '); uartputc_sync('\b');
    800002ac:	4521                	li	a0,8
    800002ae:	00000097          	auipc	ra,0x0
    800002b2:	578080e7          	jalr	1400(ra) # 80000826 <uartputc_sync>
    800002b6:	02000513          	li	a0,32
    800002ba:	00000097          	auipc	ra,0x0
    800002be:	56c080e7          	jalr	1388(ra) # 80000826 <uartputc_sync>
    800002c2:	4521                	li	a0,8
    800002c4:	00000097          	auipc	ra,0x0
    800002c8:	562080e7          	jalr	1378(ra) # 80000826 <uartputc_sync>
    800002cc:	bfe1                	j	800002a4 <consputc+0x18>

00000000800002ce <consoleintr>:
// do erase/kill processing, append to cons.buf,
// wake up consoleread() if a whole line has arrived.
//
void
consoleintr(int c)
{
    800002ce:	1101                	addi	sp,sp,-32
    800002d0:	ec06                	sd	ra,24(sp)
    800002d2:	e822                	sd	s0,16(sp)
    800002d4:	e426                	sd	s1,8(sp)
    800002d6:	e04a                	sd	s2,0(sp)
    800002d8:	1000                	addi	s0,sp,32
    800002da:	84aa                	mv	s1,a0
  acquire(&cons.lock);
    800002dc:	00011517          	auipc	a0,0x11
    800002e0:	55450513          	addi	a0,a0,1364 # 80011830 <cons>
    800002e4:	00001097          	auipc	ra,0x1
    800002e8:	97e080e7          	jalr	-1666(ra) # 80000c62 <acquire>

  switch(c){
    800002ec:	47c1                	li	a5,16
    800002ee:	12f48463          	beq	s1,a5,80000416 <consoleintr+0x148>
    800002f2:	0297df63          	ble	s1,a5,80000330 <consoleintr+0x62>
    800002f6:	47d5                	li	a5,21
    800002f8:	0af48863          	beq	s1,a5,800003a8 <consoleintr+0xda>
    800002fc:	07f00793          	li	a5,127
    80000300:	02f49b63          	bne	s1,a5,80000336 <consoleintr+0x68>
      consputc(BACKSPACE);
    }
    break;
  case C('H'): // Backspace
  case '\x7f':
    if(cons.e != cons.w){
    80000304:	00011717          	auipc	a4,0x11
    80000308:	52c70713          	addi	a4,a4,1324 # 80011830 <cons>
    8000030c:	0a072783          	lw	a5,160(a4)
    80000310:	09c72703          	lw	a4,156(a4)
    80000314:	10f70563          	beq	a4,a5,8000041e <consoleintr+0x150>
      cons.e--;
    80000318:	37fd                	addiw	a5,a5,-1
    8000031a:	00011717          	auipc	a4,0x11
    8000031e:	5af72b23          	sw	a5,1462(a4) # 800118d0 <cons+0xa0>
      consputc(BACKSPACE);
    80000322:	10000513          	li	a0,256
    80000326:	00000097          	auipc	ra,0x0
    8000032a:	f66080e7          	jalr	-154(ra) # 8000028c <consputc>
    8000032e:	a8c5                	j	8000041e <consoleintr+0x150>
  switch(c){
    80000330:	47a1                	li	a5,8
    80000332:	fcf489e3          	beq	s1,a5,80000304 <consoleintr+0x36>
    }
    break;
  default:
    if(c != 0 && cons.e-cons.r < INPUT_BUF){
    80000336:	c4e5                	beqz	s1,8000041e <consoleintr+0x150>
    80000338:	00011717          	auipc	a4,0x11
    8000033c:	4f870713          	addi	a4,a4,1272 # 80011830 <cons>
    80000340:	0a072783          	lw	a5,160(a4)
    80000344:	09872703          	lw	a4,152(a4)
    80000348:	9f99                	subw	a5,a5,a4
    8000034a:	07f00713          	li	a4,127
    8000034e:	0cf76863          	bltu	a4,a5,8000041e <consoleintr+0x150>
      c = (c == '\r') ? '\n' : c;
    80000352:	47b5                	li	a5,13
    80000354:	0ef48363          	beq	s1,a5,8000043a <consoleintr+0x16c>

      // echo back to the user.
      consputc(c);
    80000358:	8526                	mv	a0,s1
    8000035a:	00000097          	auipc	ra,0x0
    8000035e:	f32080e7          	jalr	-206(ra) # 8000028c <consputc>

      // store for consumption by consoleread().
      cons.buf[cons.e++ % INPUT_BUF] = c;
    80000362:	00011797          	auipc	a5,0x11
    80000366:	4ce78793          	addi	a5,a5,1230 # 80011830 <cons>
    8000036a:	0a07a703          	lw	a4,160(a5)
    8000036e:	0017069b          	addiw	a3,a4,1
    80000372:	0006861b          	sext.w	a2,a3
    80000376:	0ad7a023          	sw	a3,160(a5)
    8000037a:	07f77713          	andi	a4,a4,127
    8000037e:	97ba                	add	a5,a5,a4
    80000380:	00978c23          	sb	s1,24(a5)

      if(c == '\n' || c == C('D') || cons.e == cons.r+INPUT_BUF){
    80000384:	47a9                	li	a5,10
    80000386:	0ef48163          	beq	s1,a5,80000468 <consoleintr+0x19a>
    8000038a:	4791                	li	a5,4
    8000038c:	0cf48e63          	beq	s1,a5,80000468 <consoleintr+0x19a>
    80000390:	00011797          	auipc	a5,0x11
    80000394:	4a078793          	addi	a5,a5,1184 # 80011830 <cons>
    80000398:	0987a783          	lw	a5,152(a5)
    8000039c:	0807879b          	addiw	a5,a5,128
    800003a0:	06f61f63          	bne	a2,a5,8000041e <consoleintr+0x150>
      cons.buf[cons.e++ % INPUT_BUF] = c;
    800003a4:	863e                	mv	a2,a5
    800003a6:	a0c9                	j	80000468 <consoleintr+0x19a>
    while(cons.e != cons.w &&
    800003a8:	00011717          	auipc	a4,0x11
    800003ac:	48870713          	addi	a4,a4,1160 # 80011830 <cons>
    800003b0:	0a072783          	lw	a5,160(a4)
    800003b4:	09c72703          	lw	a4,156(a4)
    800003b8:	06f70363          	beq	a4,a5,8000041e <consoleintr+0x150>
          cons.buf[(cons.e-1) % INPUT_BUF] != '\n'){
    800003bc:	37fd                	addiw	a5,a5,-1
    800003be:	0007871b          	sext.w	a4,a5
    800003c2:	07f7f793          	andi	a5,a5,127
    800003c6:	00011697          	auipc	a3,0x11
    800003ca:	46a68693          	addi	a3,a3,1130 # 80011830 <cons>
    800003ce:	97b6                	add	a5,a5,a3
    while(cons.e != cons.w &&
    800003d0:	0187c683          	lbu	a3,24(a5)
    800003d4:	47a9                	li	a5,10
      cons.e--;
    800003d6:	00011497          	auipc	s1,0x11
    800003da:	45a48493          	addi	s1,s1,1114 # 80011830 <cons>
    while(cons.e != cons.w &&
    800003de:	4929                	li	s2,10
    800003e0:	02f68f63          	beq	a3,a5,8000041e <consoleintr+0x150>
      cons.e--;
    800003e4:	0ae4a023          	sw	a4,160(s1)
      consputc(BACKSPACE);
    800003e8:	10000513          	li	a0,256
    800003ec:	00000097          	auipc	ra,0x0
    800003f0:	ea0080e7          	jalr	-352(ra) # 8000028c <consputc>
    while(cons.e != cons.w &&
    800003f4:	0a04a783          	lw	a5,160(s1)
    800003f8:	09c4a703          	lw	a4,156(s1)
    800003fc:	02f70163          	beq	a4,a5,8000041e <consoleintr+0x150>
          cons.buf[(cons.e-1) % INPUT_BUF] != '\n'){
    80000400:	37fd                	addiw	a5,a5,-1
    80000402:	0007871b          	sext.w	a4,a5
    80000406:	07f7f793          	andi	a5,a5,127
    8000040a:	97a6                	add	a5,a5,s1
    while(cons.e != cons.w &&
    8000040c:	0187c783          	lbu	a5,24(a5)
    80000410:	fd279ae3          	bne	a5,s2,800003e4 <consoleintr+0x116>
    80000414:	a029                	j	8000041e <consoleintr+0x150>
    procdump();
    80000416:	00002097          	auipc	ra,0x2
    8000041a:	1aa080e7          	jalr	426(ra) # 800025c0 <procdump>
      }
    }
    break;
  }
  
  release(&cons.lock);
    8000041e:	00011517          	auipc	a0,0x11
    80000422:	41250513          	addi	a0,a0,1042 # 80011830 <cons>
    80000426:	00001097          	auipc	ra,0x1
    8000042a:	8f0080e7          	jalr	-1808(ra) # 80000d16 <release>
}
    8000042e:	60e2                	ld	ra,24(sp)
    80000430:	6442                	ld	s0,16(sp)
    80000432:	64a2                	ld	s1,8(sp)
    80000434:	6902                	ld	s2,0(sp)
    80000436:	6105                	addi	sp,sp,32
    80000438:	8082                	ret
      consputc(c);
    8000043a:	4529                	li	a0,10
    8000043c:	00000097          	auipc	ra,0x0
    80000440:	e50080e7          	jalr	-432(ra) # 8000028c <consputc>
      cons.buf[cons.e++ % INPUT_BUF] = c;
    80000444:	00011797          	auipc	a5,0x11
    80000448:	3ec78793          	addi	a5,a5,1004 # 80011830 <cons>
    8000044c:	0a07a703          	lw	a4,160(a5)
    80000450:	0017069b          	addiw	a3,a4,1
    80000454:	0006861b          	sext.w	a2,a3
    80000458:	0ad7a023          	sw	a3,160(a5)
    8000045c:	07f77713          	andi	a4,a4,127
    80000460:	97ba                	add	a5,a5,a4
    80000462:	4729                	li	a4,10
    80000464:	00e78c23          	sb	a4,24(a5)
        cons.w = cons.e;
    80000468:	00011797          	auipc	a5,0x11
    8000046c:	46c7a223          	sw	a2,1124(a5) # 800118cc <cons+0x9c>
        wakeup(&cons.r);
    80000470:	00011517          	auipc	a0,0x11
    80000474:	45850513          	addi	a0,a0,1112 # 800118c8 <cons+0x98>
    80000478:	00002097          	auipc	ra,0x2
    8000047c:	fc0080e7          	jalr	-64(ra) # 80002438 <wakeup>
    80000480:	bf79                	j	8000041e <consoleintr+0x150>

0000000080000482 <consoleinit>:

void
consoleinit(void)
{
    80000482:	1141                	addi	sp,sp,-16
    80000484:	e406                	sd	ra,8(sp)
    80000486:	e022                	sd	s0,0(sp)
    80000488:	0800                	addi	s0,sp,16
  initlock(&cons.lock, "cons");
    8000048a:	00008597          	auipc	a1,0x8
    8000048e:	b8658593          	addi	a1,a1,-1146 # 80008010 <etext+0x10>
    80000492:	00011517          	auipc	a0,0x11
    80000496:	39e50513          	addi	a0,a0,926 # 80011830 <cons>
    8000049a:	00000097          	auipc	ra,0x0
    8000049e:	738080e7          	jalr	1848(ra) # 80000bd2 <initlock>

  uartinit();
    800004a2:	00000097          	auipc	ra,0x0
    800004a6:	334080e7          	jalr	820(ra) # 800007d6 <uartinit>

  // connect read and write system calls
  // to consoleread and consolewrite.
  devsw[CONSOLE].read = consoleread;
    800004aa:	00021797          	auipc	a5,0x21
    800004ae:	50678793          	addi	a5,a5,1286 # 800219b0 <devsw>
    800004b2:	00000717          	auipc	a4,0x0
    800004b6:	cbe70713          	addi	a4,a4,-834 # 80000170 <consoleread>
    800004ba:	eb98                	sd	a4,16(a5)
  devsw[CONSOLE].write = consolewrite;
    800004bc:	00000717          	auipc	a4,0x0
    800004c0:	c3270713          	addi	a4,a4,-974 # 800000ee <consolewrite>
    800004c4:	ef98                	sd	a4,24(a5)
}
    800004c6:	60a2                	ld	ra,8(sp)
    800004c8:	6402                	ld	s0,0(sp)
    800004ca:	0141                	addi	sp,sp,16
    800004cc:	8082                	ret

00000000800004ce <printint>:

static char digits[] = "0123456789abcdef";

static void
printint(int xx, int base, int sign)
{
    800004ce:	7179                	addi	sp,sp,-48
    800004d0:	f406                	sd	ra,40(sp)
    800004d2:	f022                	sd	s0,32(sp)
    800004d4:	ec26                	sd	s1,24(sp)
    800004d6:	e84a                	sd	s2,16(sp)
    800004d8:	1800                	addi	s0,sp,48
  char buf[16];
  int i;
  uint x;

  if(sign && (sign = xx < 0))
    800004da:	c219                	beqz	a2,800004e0 <printint+0x12>
    800004dc:	00054d63          	bltz	a0,800004f6 <printint+0x28>
    x = -xx;
  else
    x = xx;
    800004e0:	2501                	sext.w	a0,a0
    800004e2:	4881                	li	a7,0
    800004e4:	fd040713          	addi	a4,s0,-48

  i = 0;
    800004e8:	4601                	li	a2,0
  do {
    buf[i++] = digits[x % base];
    800004ea:	2581                	sext.w	a1,a1
    800004ec:	00008817          	auipc	a6,0x8
    800004f0:	b2c80813          	addi	a6,a6,-1236 # 80008018 <digits>
    800004f4:	a801                	j	80000504 <printint+0x36>
    x = -xx;
    800004f6:	40a0053b          	negw	a0,a0
    800004fa:	2501                	sext.w	a0,a0
  if(sign && (sign = xx < 0))
    800004fc:	4885                	li	a7,1
    x = -xx;
    800004fe:	b7dd                	j	800004e4 <printint+0x16>
  } while((x /= base) != 0);
    80000500:	853e                	mv	a0,a5
    buf[i++] = digits[x % base];
    80000502:	8636                	mv	a2,a3
    80000504:	0016069b          	addiw	a3,a2,1
    80000508:	02b577bb          	remuw	a5,a0,a1
    8000050c:	1782                	slli	a5,a5,0x20
    8000050e:	9381                	srli	a5,a5,0x20
    80000510:	97c2                	add	a5,a5,a6
    80000512:	0007c783          	lbu	a5,0(a5)
    80000516:	00f70023          	sb	a5,0(a4)
  } while((x /= base) != 0);
    8000051a:	0705                	addi	a4,a4,1
    8000051c:	02b557bb          	divuw	a5,a0,a1
    80000520:	feb570e3          	bleu	a1,a0,80000500 <printint+0x32>

  if(sign)
    80000524:	00088b63          	beqz	a7,8000053a <printint+0x6c>
    buf[i++] = '-';
    80000528:	fe040793          	addi	a5,s0,-32
    8000052c:	96be                	add	a3,a3,a5
    8000052e:	02d00793          	li	a5,45
    80000532:	fef68823          	sb	a5,-16(a3)
    80000536:	0026069b          	addiw	a3,a2,2

  while(--i >= 0)
    8000053a:	02d05763          	blez	a3,80000568 <printint+0x9a>
    8000053e:	fd040793          	addi	a5,s0,-48
    80000542:	00d784b3          	add	s1,a5,a3
    80000546:	fff78913          	addi	s2,a5,-1
    8000054a:	9936                	add	s2,s2,a3
    8000054c:	36fd                	addiw	a3,a3,-1
    8000054e:	1682                	slli	a3,a3,0x20
    80000550:	9281                	srli	a3,a3,0x20
    80000552:	40d90933          	sub	s2,s2,a3
    consputc(buf[i]);
    80000556:	fff4c503          	lbu	a0,-1(s1)
    8000055a:	00000097          	auipc	ra,0x0
    8000055e:	d32080e7          	jalr	-718(ra) # 8000028c <consputc>
  while(--i >= 0)
    80000562:	14fd                	addi	s1,s1,-1
    80000564:	ff2499e3          	bne	s1,s2,80000556 <printint+0x88>
}
    80000568:	70a2                	ld	ra,40(sp)
    8000056a:	7402                	ld	s0,32(sp)
    8000056c:	64e2                	ld	s1,24(sp)
    8000056e:	6942                	ld	s2,16(sp)
    80000570:	6145                	addi	sp,sp,48
    80000572:	8082                	ret

0000000080000574 <panic>:
    release(&pr.lock);
}

void
panic(char *s)
{
    80000574:	1101                	addi	sp,sp,-32
    80000576:	ec06                	sd	ra,24(sp)
    80000578:	e822                	sd	s0,16(sp)
    8000057a:	e426                	sd	s1,8(sp)
    8000057c:	1000                	addi	s0,sp,32
    8000057e:	84aa                	mv	s1,a0
  pr.locking = 0;
    80000580:	00011797          	auipc	a5,0x11
    80000584:	3607a823          	sw	zero,880(a5) # 800118f0 <pr+0x18>
  printf("panic: ");
    80000588:	00008517          	auipc	a0,0x8
    8000058c:	aa850513          	addi	a0,a0,-1368 # 80008030 <digits+0x18>
    80000590:	00000097          	auipc	ra,0x0
    80000594:	02e080e7          	jalr	46(ra) # 800005be <printf>
  printf(s);
    80000598:	8526                	mv	a0,s1
    8000059a:	00000097          	auipc	ra,0x0
    8000059e:	024080e7          	jalr	36(ra) # 800005be <printf>
  printf("\n");
    800005a2:	00008517          	auipc	a0,0x8
    800005a6:	b2650513          	addi	a0,a0,-1242 # 800080c8 <digits+0xb0>
    800005aa:	00000097          	auipc	ra,0x0
    800005ae:	014080e7          	jalr	20(ra) # 800005be <printf>
  panicked = 1; // freeze uart output from other CPUs
    800005b2:	4785                	li	a5,1
    800005b4:	00009717          	auipc	a4,0x9
    800005b8:	a4f72623          	sw	a5,-1460(a4) # 80009000 <panicked>
  for(;;)
    800005bc:	a001                	j	800005bc <panic+0x48>

00000000800005be <printf>:
{
    800005be:	7131                	addi	sp,sp,-192
    800005c0:	fc86                	sd	ra,120(sp)
    800005c2:	f8a2                	sd	s0,112(sp)
    800005c4:	f4a6                	sd	s1,104(sp)
    800005c6:	f0ca                	sd	s2,96(sp)
    800005c8:	ecce                	sd	s3,88(sp)
    800005ca:	e8d2                	sd	s4,80(sp)
    800005cc:	e4d6                	sd	s5,72(sp)
    800005ce:	e0da                	sd	s6,64(sp)
    800005d0:	fc5e                	sd	s7,56(sp)
    800005d2:	f862                	sd	s8,48(sp)
    800005d4:	f466                	sd	s9,40(sp)
    800005d6:	f06a                	sd	s10,32(sp)
    800005d8:	ec6e                	sd	s11,24(sp)
    800005da:	0100                	addi	s0,sp,128
    800005dc:	8aaa                	mv	s5,a0
    800005de:	e40c                	sd	a1,8(s0)
    800005e0:	e810                	sd	a2,16(s0)
    800005e2:	ec14                	sd	a3,24(s0)
    800005e4:	f018                	sd	a4,32(s0)
    800005e6:	f41c                	sd	a5,40(s0)
    800005e8:	03043823          	sd	a6,48(s0)
    800005ec:	03143c23          	sd	a7,56(s0)
  locking = pr.locking;
    800005f0:	00011797          	auipc	a5,0x11
    800005f4:	2e878793          	addi	a5,a5,744 # 800118d8 <pr>
    800005f8:	0187ad83          	lw	s11,24(a5)
  if(locking)
    800005fc:	020d9b63          	bnez	s11,80000632 <printf+0x74>
  if (fmt == 0)
    80000600:	020a8f63          	beqz	s5,8000063e <printf+0x80>
  va_start(ap, fmt);
    80000604:	00840793          	addi	a5,s0,8
    80000608:	f8f43423          	sd	a5,-120(s0)
  for(i = 0; (c = fmt[i] & 0xff) != 0; i++){
    8000060c:	000ac503          	lbu	a0,0(s5)
    80000610:	16050063          	beqz	a0,80000770 <printf+0x1b2>
    80000614:	4481                	li	s1,0
    if(c != '%'){
    80000616:	02500a13          	li	s4,37
    switch(c){
    8000061a:	07000b13          	li	s6,112
  consputc('x');
    8000061e:	4d41                	li	s10,16
    consputc(digits[x >> (sizeof(uint64) * 8 - 4)]);
    80000620:	00008b97          	auipc	s7,0x8
    80000624:	9f8b8b93          	addi	s7,s7,-1544 # 80008018 <digits>
    switch(c){
    80000628:	07300c93          	li	s9,115
    8000062c:	06400c13          	li	s8,100
    80000630:	a815                	j	80000664 <printf+0xa6>
    acquire(&pr.lock);
    80000632:	853e                	mv	a0,a5
    80000634:	00000097          	auipc	ra,0x0
    80000638:	62e080e7          	jalr	1582(ra) # 80000c62 <acquire>
    8000063c:	b7d1                	j	80000600 <printf+0x42>
    panic("null fmt");
    8000063e:	00008517          	auipc	a0,0x8
    80000642:	a0250513          	addi	a0,a0,-1534 # 80008040 <digits+0x28>
    80000646:	00000097          	auipc	ra,0x0
    8000064a:	f2e080e7          	jalr	-210(ra) # 80000574 <panic>
      consputc(c);
    8000064e:	00000097          	auipc	ra,0x0
    80000652:	c3e080e7          	jalr	-962(ra) # 8000028c <consputc>
  for(i = 0; (c = fmt[i] & 0xff) != 0; i++){
    80000656:	2485                	addiw	s1,s1,1
    80000658:	009a87b3          	add	a5,s5,s1
    8000065c:	0007c503          	lbu	a0,0(a5)
    80000660:	10050863          	beqz	a0,80000770 <printf+0x1b2>
    if(c != '%'){
    80000664:	ff4515e3          	bne	a0,s4,8000064e <printf+0x90>
    c = fmt[++i] & 0xff;
    80000668:	2485                	addiw	s1,s1,1
    8000066a:	009a87b3          	add	a5,s5,s1
    8000066e:	0007c783          	lbu	a5,0(a5)
    80000672:	0007891b          	sext.w	s2,a5
    if(c == 0)
    80000676:	0e090d63          	beqz	s2,80000770 <printf+0x1b2>
    switch(c){
    8000067a:	05678a63          	beq	a5,s6,800006ce <printf+0x110>
    8000067e:	02fb7663          	bleu	a5,s6,800006aa <printf+0xec>
    80000682:	09978963          	beq	a5,s9,80000714 <printf+0x156>
    80000686:	07800713          	li	a4,120
    8000068a:	0ce79863          	bne	a5,a4,8000075a <printf+0x19c>
      printint(va_arg(ap, int), 16, 1);
    8000068e:	f8843783          	ld	a5,-120(s0)
    80000692:	00878713          	addi	a4,a5,8
    80000696:	f8e43423          	sd	a4,-120(s0)
    8000069a:	4605                	li	a2,1
    8000069c:	85ea                	mv	a1,s10
    8000069e:	4388                	lw	a0,0(a5)
    800006a0:	00000097          	auipc	ra,0x0
    800006a4:	e2e080e7          	jalr	-466(ra) # 800004ce <printint>
      break;
    800006a8:	b77d                	j	80000656 <printf+0x98>
    switch(c){
    800006aa:	0b478263          	beq	a5,s4,8000074e <printf+0x190>
    800006ae:	0b879663          	bne	a5,s8,8000075a <printf+0x19c>
      printint(va_arg(ap, int), 10, 1);
    800006b2:	f8843783          	ld	a5,-120(s0)
    800006b6:	00878713          	addi	a4,a5,8
    800006ba:	f8e43423          	sd	a4,-120(s0)
    800006be:	4605                	li	a2,1
    800006c0:	45a9                	li	a1,10
    800006c2:	4388                	lw	a0,0(a5)
    800006c4:	00000097          	auipc	ra,0x0
    800006c8:	e0a080e7          	jalr	-502(ra) # 800004ce <printint>
      break;
    800006cc:	b769                	j	80000656 <printf+0x98>
      printptr(va_arg(ap, uint64));
    800006ce:	f8843783          	ld	a5,-120(s0)
    800006d2:	00878713          	addi	a4,a5,8
    800006d6:	f8e43423          	sd	a4,-120(s0)
    800006da:	0007b983          	ld	s3,0(a5)
  consputc('0');
    800006de:	03000513          	li	a0,48
    800006e2:	00000097          	auipc	ra,0x0
    800006e6:	baa080e7          	jalr	-1110(ra) # 8000028c <consputc>
  consputc('x');
    800006ea:	07800513          	li	a0,120
    800006ee:	00000097          	auipc	ra,0x0
    800006f2:	b9e080e7          	jalr	-1122(ra) # 8000028c <consputc>
    800006f6:	896a                	mv	s2,s10
    consputc(digits[x >> (sizeof(uint64) * 8 - 4)]);
    800006f8:	03c9d793          	srli	a5,s3,0x3c
    800006fc:	97de                	add	a5,a5,s7
    800006fe:	0007c503          	lbu	a0,0(a5)
    80000702:	00000097          	auipc	ra,0x0
    80000706:	b8a080e7          	jalr	-1142(ra) # 8000028c <consputc>
  for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4)
    8000070a:	0992                	slli	s3,s3,0x4
    8000070c:	397d                	addiw	s2,s2,-1
    8000070e:	fe0915e3          	bnez	s2,800006f8 <printf+0x13a>
    80000712:	b791                	j	80000656 <printf+0x98>
      if((s = va_arg(ap, char*)) == 0)
    80000714:	f8843783          	ld	a5,-120(s0)
    80000718:	00878713          	addi	a4,a5,8
    8000071c:	f8e43423          	sd	a4,-120(s0)
    80000720:	0007b903          	ld	s2,0(a5)
    80000724:	00090e63          	beqz	s2,80000740 <printf+0x182>
      for(; *s; s++)
    80000728:	00094503          	lbu	a0,0(s2)
    8000072c:	d50d                	beqz	a0,80000656 <printf+0x98>
        consputc(*s);
    8000072e:	00000097          	auipc	ra,0x0
    80000732:	b5e080e7          	jalr	-1186(ra) # 8000028c <consputc>
      for(; *s; s++)
    80000736:	0905                	addi	s2,s2,1
    80000738:	00094503          	lbu	a0,0(s2)
    8000073c:	f96d                	bnez	a0,8000072e <printf+0x170>
    8000073e:	bf21                	j	80000656 <printf+0x98>
        s = "(null)";
    80000740:	00008917          	auipc	s2,0x8
    80000744:	8f890913          	addi	s2,s2,-1800 # 80008038 <digits+0x20>
      for(; *s; s++)
    80000748:	02800513          	li	a0,40
    8000074c:	b7cd                	j	8000072e <printf+0x170>
      consputc('%');
    8000074e:	8552                	mv	a0,s4
    80000750:	00000097          	auipc	ra,0x0
    80000754:	b3c080e7          	jalr	-1220(ra) # 8000028c <consputc>
      break;
    80000758:	bdfd                	j	80000656 <printf+0x98>
      consputc('%');
    8000075a:	8552                	mv	a0,s4
    8000075c:	00000097          	auipc	ra,0x0
    80000760:	b30080e7          	jalr	-1232(ra) # 8000028c <consputc>
      consputc(c);
    80000764:	854a                	mv	a0,s2
    80000766:	00000097          	auipc	ra,0x0
    8000076a:	b26080e7          	jalr	-1242(ra) # 8000028c <consputc>
      break;
    8000076e:	b5e5                	j	80000656 <printf+0x98>
  if(locking)
    80000770:	020d9163          	bnez	s11,80000792 <printf+0x1d4>
}
    80000774:	70e6                	ld	ra,120(sp)
    80000776:	7446                	ld	s0,112(sp)
    80000778:	74a6                	ld	s1,104(sp)
    8000077a:	7906                	ld	s2,96(sp)
    8000077c:	69e6                	ld	s3,88(sp)
    8000077e:	6a46                	ld	s4,80(sp)
    80000780:	6aa6                	ld	s5,72(sp)
    80000782:	6b06                	ld	s6,64(sp)
    80000784:	7be2                	ld	s7,56(sp)
    80000786:	7c42                	ld	s8,48(sp)
    80000788:	7ca2                	ld	s9,40(sp)
    8000078a:	7d02                	ld	s10,32(sp)
    8000078c:	6de2                	ld	s11,24(sp)
    8000078e:	6129                	addi	sp,sp,192
    80000790:	8082                	ret
    release(&pr.lock);
    80000792:	00011517          	auipc	a0,0x11
    80000796:	14650513          	addi	a0,a0,326 # 800118d8 <pr>
    8000079a:	00000097          	auipc	ra,0x0
    8000079e:	57c080e7          	jalr	1404(ra) # 80000d16 <release>
}
    800007a2:	bfc9                	j	80000774 <printf+0x1b6>

00000000800007a4 <printfinit>:
    ;
}

void
printfinit(void)
{
    800007a4:	1101                	addi	sp,sp,-32
    800007a6:	ec06                	sd	ra,24(sp)
    800007a8:	e822                	sd	s0,16(sp)
    800007aa:	e426                	sd	s1,8(sp)
    800007ac:	1000                	addi	s0,sp,32
  initlock(&pr.lock, "pr");
    800007ae:	00011497          	auipc	s1,0x11
    800007b2:	12a48493          	addi	s1,s1,298 # 800118d8 <pr>
    800007b6:	00008597          	auipc	a1,0x8
    800007ba:	89a58593          	addi	a1,a1,-1894 # 80008050 <digits+0x38>
    800007be:	8526                	mv	a0,s1
    800007c0:	00000097          	auipc	ra,0x0
    800007c4:	412080e7          	jalr	1042(ra) # 80000bd2 <initlock>
  pr.locking = 1;
    800007c8:	4785                	li	a5,1
    800007ca:	cc9c                	sw	a5,24(s1)
}
    800007cc:	60e2                	ld	ra,24(sp)
    800007ce:	6442                	ld	s0,16(sp)
    800007d0:	64a2                	ld	s1,8(sp)
    800007d2:	6105                	addi	sp,sp,32
    800007d4:	8082                	ret

00000000800007d6 <uartinit>:

void uartstart();

void
uartinit(void)
{
    800007d6:	1141                	addi	sp,sp,-16
    800007d8:	e406                	sd	ra,8(sp)
    800007da:	e022                	sd	s0,0(sp)
    800007dc:	0800                	addi	s0,sp,16
  // disable interrupts.
  WriteReg(IER, 0x00);
    800007de:	100007b7          	lui	a5,0x10000
    800007e2:	000780a3          	sb	zero,1(a5) # 10000001 <_entry-0x6fffffff>

  // special mode to set baud rate.
  WriteReg(LCR, LCR_BAUD_LATCH);
    800007e6:	f8000713          	li	a4,-128
    800007ea:	00e781a3          	sb	a4,3(a5)

  // LSB for baud rate of 38.4K.
  WriteReg(0, 0x03);
    800007ee:	470d                	li	a4,3
    800007f0:	00e78023          	sb	a4,0(a5)

  // MSB for baud rate of 38.4K.
  WriteReg(1, 0x00);
    800007f4:	000780a3          	sb	zero,1(a5)

  // leave set-baud mode,
  // and set word length to 8 bits, no parity.
  WriteReg(LCR, LCR_EIGHT_BITS);
    800007f8:	00e781a3          	sb	a4,3(a5)

  // reset and enable FIFOs.
  WriteReg(FCR, FCR_FIFO_ENABLE | FCR_FIFO_CLEAR);
    800007fc:	469d                	li	a3,7
    800007fe:	00d78123          	sb	a3,2(a5)

  // enable transmit and receive interrupts.
  WriteReg(IER, IER_TX_ENABLE | IER_RX_ENABLE);
    80000802:	00e780a3          	sb	a4,1(a5)

  initlock(&uart_tx_lock, "uart");
    80000806:	00008597          	auipc	a1,0x8
    8000080a:	85258593          	addi	a1,a1,-1966 # 80008058 <digits+0x40>
    8000080e:	00011517          	auipc	a0,0x11
    80000812:	0ea50513          	addi	a0,a0,234 # 800118f8 <uart_tx_lock>
    80000816:	00000097          	auipc	ra,0x0
    8000081a:	3bc080e7          	jalr	956(ra) # 80000bd2 <initlock>
}
    8000081e:	60a2                	ld	ra,8(sp)
    80000820:	6402                	ld	s0,0(sp)
    80000822:	0141                	addi	sp,sp,16
    80000824:	8082                	ret

0000000080000826 <uartputc_sync>:
// use interrupts, for use by kernel printf() and
// to echo characters. it spins waiting for the uart's
// output register to be empty.
void
uartputc_sync(int c)
{
    80000826:	1101                	addi	sp,sp,-32
    80000828:	ec06                	sd	ra,24(sp)
    8000082a:	e822                	sd	s0,16(sp)
    8000082c:	e426                	sd	s1,8(sp)
    8000082e:	1000                	addi	s0,sp,32
    80000830:	84aa                	mv	s1,a0
  push_off();
    80000832:	00000097          	auipc	ra,0x0
    80000836:	3e4080e7          	jalr	996(ra) # 80000c16 <push_off>

  if(panicked){
    8000083a:	00008797          	auipc	a5,0x8
    8000083e:	7c678793          	addi	a5,a5,1990 # 80009000 <panicked>
    80000842:	439c                	lw	a5,0(a5)
    80000844:	2781                	sext.w	a5,a5
    for(;;)
      ;
  }

  // wait for Transmit Holding Empty to be set in LSR.
  while((ReadReg(LSR) & LSR_TX_IDLE) == 0)
    80000846:	10000737          	lui	a4,0x10000
  if(panicked){
    8000084a:	c391                	beqz	a5,8000084e <uartputc_sync+0x28>
    for(;;)
    8000084c:	a001                	j	8000084c <uartputc_sync+0x26>
  while((ReadReg(LSR) & LSR_TX_IDLE) == 0)
    8000084e:	00574783          	lbu	a5,5(a4) # 10000005 <_entry-0x6ffffffb>
    80000852:	0ff7f793          	andi	a5,a5,255
    80000856:	0207f793          	andi	a5,a5,32
    8000085a:	dbf5                	beqz	a5,8000084e <uartputc_sync+0x28>
    ;
  WriteReg(THR, c);
    8000085c:	0ff4f793          	andi	a5,s1,255
    80000860:	10000737          	lui	a4,0x10000
    80000864:	00f70023          	sb	a5,0(a4) # 10000000 <_entry-0x70000000>

  pop_off();
    80000868:	00000097          	auipc	ra,0x0
    8000086c:	44e080e7          	jalr	1102(ra) # 80000cb6 <pop_off>
}
    80000870:	60e2                	ld	ra,24(sp)
    80000872:	6442                	ld	s0,16(sp)
    80000874:	64a2                	ld	s1,8(sp)
    80000876:	6105                	addi	sp,sp,32
    80000878:	8082                	ret

000000008000087a <uartstart>:
// called from both the top- and bottom-half.
void
uartstart()
{
  while(1){
    if(uart_tx_w == uart_tx_r){
    8000087a:	00008797          	auipc	a5,0x8
    8000087e:	78a78793          	addi	a5,a5,1930 # 80009004 <uart_tx_r>
    80000882:	439c                	lw	a5,0(a5)
    80000884:	00008717          	auipc	a4,0x8
    80000888:	78470713          	addi	a4,a4,1924 # 80009008 <uart_tx_w>
    8000088c:	4318                	lw	a4,0(a4)
    8000088e:	08f70b63          	beq	a4,a5,80000924 <uartstart+0xaa>
      // transmit buffer is empty.
      return;
    }
    
    if((ReadReg(LSR) & LSR_TX_IDLE) == 0){
    80000892:	10000737          	lui	a4,0x10000
    80000896:	00574703          	lbu	a4,5(a4) # 10000005 <_entry-0x6ffffffb>
    8000089a:	0ff77713          	andi	a4,a4,255
    8000089e:	02077713          	andi	a4,a4,32
    800008a2:	c349                	beqz	a4,80000924 <uartstart+0xaa>
{
    800008a4:	7139                	addi	sp,sp,-64
    800008a6:	fc06                	sd	ra,56(sp)
    800008a8:	f822                	sd	s0,48(sp)
    800008aa:	f426                	sd	s1,40(sp)
    800008ac:	f04a                	sd	s2,32(sp)
    800008ae:	ec4e                	sd	s3,24(sp)
    800008b0:	e852                	sd	s4,16(sp)
    800008b2:	e456                	sd	s5,8(sp)
    800008b4:	0080                	addi	s0,sp,64
      // so we cannot give it another byte.
      // it will interrupt when it's ready for a new byte.
      return;
    }
    
    int c = uart_tx_buf[uart_tx_r];
    800008b6:	00011a17          	auipc	s4,0x11
    800008ba:	042a0a13          	addi	s4,s4,66 # 800118f8 <uart_tx_lock>
    uart_tx_r = (uart_tx_r + 1) % UART_TX_BUF_SIZE;
    800008be:	00008497          	auipc	s1,0x8
    800008c2:	74648493          	addi	s1,s1,1862 # 80009004 <uart_tx_r>
    
    // maybe uartputc() is waiting for space in the buffer.
    wakeup(&uart_tx_r);
    
    WriteReg(THR, c);
    800008c6:	10000937          	lui	s2,0x10000
    if(uart_tx_w == uart_tx_r){
    800008ca:	00008997          	auipc	s3,0x8
    800008ce:	73e98993          	addi	s3,s3,1854 # 80009008 <uart_tx_w>
    int c = uart_tx_buf[uart_tx_r];
    800008d2:	00fa0733          	add	a4,s4,a5
    800008d6:	01874a83          	lbu	s5,24(a4)
    uart_tx_r = (uart_tx_r + 1) % UART_TX_BUF_SIZE;
    800008da:	2785                	addiw	a5,a5,1
    800008dc:	41f7d71b          	sraiw	a4,a5,0x1f
    800008e0:	01b7571b          	srliw	a4,a4,0x1b
    800008e4:	9fb9                	addw	a5,a5,a4
    800008e6:	8bfd                	andi	a5,a5,31
    800008e8:	9f99                	subw	a5,a5,a4
    800008ea:	c09c                	sw	a5,0(s1)
    wakeup(&uart_tx_r);
    800008ec:	8526                	mv	a0,s1
    800008ee:	00002097          	auipc	ra,0x2
    800008f2:	b4a080e7          	jalr	-1206(ra) # 80002438 <wakeup>
    WriteReg(THR, c);
    800008f6:	01590023          	sb	s5,0(s2) # 10000000 <_entry-0x70000000>
    if(uart_tx_w == uart_tx_r){
    800008fa:	409c                	lw	a5,0(s1)
    800008fc:	0009a703          	lw	a4,0(s3)
    80000900:	00f70963          	beq	a4,a5,80000912 <uartstart+0x98>
    if((ReadReg(LSR) & LSR_TX_IDLE) == 0){
    80000904:	00594703          	lbu	a4,5(s2)
    80000908:	0ff77713          	andi	a4,a4,255
    8000090c:	02077713          	andi	a4,a4,32
    80000910:	f369                	bnez	a4,800008d2 <uartstart+0x58>
  }
}
    80000912:	70e2                	ld	ra,56(sp)
    80000914:	7442                	ld	s0,48(sp)
    80000916:	74a2                	ld	s1,40(sp)
    80000918:	7902                	ld	s2,32(sp)
    8000091a:	69e2                	ld	s3,24(sp)
    8000091c:	6a42                	ld	s4,16(sp)
    8000091e:	6aa2                	ld	s5,8(sp)
    80000920:	6121                	addi	sp,sp,64
    80000922:	8082                	ret
    80000924:	8082                	ret

0000000080000926 <uartputc>:
{
    80000926:	7179                	addi	sp,sp,-48
    80000928:	f406                	sd	ra,40(sp)
    8000092a:	f022                	sd	s0,32(sp)
    8000092c:	ec26                	sd	s1,24(sp)
    8000092e:	e84a                	sd	s2,16(sp)
    80000930:	e44e                	sd	s3,8(sp)
    80000932:	e052                	sd	s4,0(sp)
    80000934:	1800                	addi	s0,sp,48
    80000936:	89aa                	mv	s3,a0
  acquire(&uart_tx_lock);
    80000938:	00011517          	auipc	a0,0x11
    8000093c:	fc050513          	addi	a0,a0,-64 # 800118f8 <uart_tx_lock>
    80000940:	00000097          	auipc	ra,0x0
    80000944:	322080e7          	jalr	802(ra) # 80000c62 <acquire>
  if(panicked){
    80000948:	00008797          	auipc	a5,0x8
    8000094c:	6b878793          	addi	a5,a5,1720 # 80009000 <panicked>
    80000950:	439c                	lw	a5,0(a5)
    80000952:	2781                	sext.w	a5,a5
    80000954:	c391                	beqz	a5,80000958 <uartputc+0x32>
    for(;;)
    80000956:	a001                	j	80000956 <uartputc+0x30>
    if(((uart_tx_w + 1) % UART_TX_BUF_SIZE) == uart_tx_r){
    80000958:	00008797          	auipc	a5,0x8
    8000095c:	6b078793          	addi	a5,a5,1712 # 80009008 <uart_tx_w>
    80000960:	4398                	lw	a4,0(a5)
    80000962:	0017079b          	addiw	a5,a4,1
    80000966:	41f7d69b          	sraiw	a3,a5,0x1f
    8000096a:	01b6d69b          	srliw	a3,a3,0x1b
    8000096e:	9fb5                	addw	a5,a5,a3
    80000970:	8bfd                	andi	a5,a5,31
    80000972:	9f95                	subw	a5,a5,a3
    80000974:	00008697          	auipc	a3,0x8
    80000978:	69068693          	addi	a3,a3,1680 # 80009004 <uart_tx_r>
    8000097c:	4294                	lw	a3,0(a3)
    8000097e:	04f69263          	bne	a3,a5,800009c2 <uartputc+0x9c>
      sleep(&uart_tx_r, &uart_tx_lock);
    80000982:	00011a17          	auipc	s4,0x11
    80000986:	f76a0a13          	addi	s4,s4,-138 # 800118f8 <uart_tx_lock>
    8000098a:	00008497          	auipc	s1,0x8
    8000098e:	67a48493          	addi	s1,s1,1658 # 80009004 <uart_tx_r>
    if(((uart_tx_w + 1) % UART_TX_BUF_SIZE) == uart_tx_r){
    80000992:	00008917          	auipc	s2,0x8
    80000996:	67690913          	addi	s2,s2,1654 # 80009008 <uart_tx_w>
      sleep(&uart_tx_r, &uart_tx_lock);
    8000099a:	85d2                	mv	a1,s4
    8000099c:	8526                	mv	a0,s1
    8000099e:	00002097          	auipc	ra,0x2
    800009a2:	914080e7          	jalr	-1772(ra) # 800022b2 <sleep>
    if(((uart_tx_w + 1) % UART_TX_BUF_SIZE) == uart_tx_r){
    800009a6:	00092703          	lw	a4,0(s2)
    800009aa:	0017079b          	addiw	a5,a4,1
    800009ae:	41f7d69b          	sraiw	a3,a5,0x1f
    800009b2:	01b6d69b          	srliw	a3,a3,0x1b
    800009b6:	9fb5                	addw	a5,a5,a3
    800009b8:	8bfd                	andi	a5,a5,31
    800009ba:	9f95                	subw	a5,a5,a3
    800009bc:	4094                	lw	a3,0(s1)
    800009be:	fcf68ee3          	beq	a3,a5,8000099a <uartputc+0x74>
      uart_tx_buf[uart_tx_w] = c;
    800009c2:	00011497          	auipc	s1,0x11
    800009c6:	f3648493          	addi	s1,s1,-202 # 800118f8 <uart_tx_lock>
    800009ca:	9726                	add	a4,a4,s1
    800009cc:	01370c23          	sb	s3,24(a4)
      uart_tx_w = (uart_tx_w + 1) % UART_TX_BUF_SIZE;
    800009d0:	00008717          	auipc	a4,0x8
    800009d4:	62f72c23          	sw	a5,1592(a4) # 80009008 <uart_tx_w>
      uartstart();
    800009d8:	00000097          	auipc	ra,0x0
    800009dc:	ea2080e7          	jalr	-350(ra) # 8000087a <uartstart>
      release(&uart_tx_lock);
    800009e0:	8526                	mv	a0,s1
    800009e2:	00000097          	auipc	ra,0x0
    800009e6:	334080e7          	jalr	820(ra) # 80000d16 <release>
}
    800009ea:	70a2                	ld	ra,40(sp)
    800009ec:	7402                	ld	s0,32(sp)
    800009ee:	64e2                	ld	s1,24(sp)
    800009f0:	6942                	ld	s2,16(sp)
    800009f2:	69a2                	ld	s3,8(sp)
    800009f4:	6a02                	ld	s4,0(sp)
    800009f6:	6145                	addi	sp,sp,48
    800009f8:	8082                	ret

00000000800009fa <uartgetc>:

// read one input character from the UART.
// return -1 if none is waiting.
int
uartgetc(void)
{
    800009fa:	1141                	addi	sp,sp,-16
    800009fc:	e422                	sd	s0,8(sp)
    800009fe:	0800                	addi	s0,sp,16
  if(ReadReg(LSR) & 0x01){
    80000a00:	100007b7          	lui	a5,0x10000
    80000a04:	0057c783          	lbu	a5,5(a5) # 10000005 <_entry-0x6ffffffb>
    80000a08:	8b85                	andi	a5,a5,1
    80000a0a:	cb91                	beqz	a5,80000a1e <uartgetc+0x24>
    // input data is ready.
    return ReadReg(RHR);
    80000a0c:	100007b7          	lui	a5,0x10000
    80000a10:	0007c503          	lbu	a0,0(a5) # 10000000 <_entry-0x70000000>
    80000a14:	0ff57513          	andi	a0,a0,255
  } else {
    return -1;
  }
}
    80000a18:	6422                	ld	s0,8(sp)
    80000a1a:	0141                	addi	sp,sp,16
    80000a1c:	8082                	ret
    return -1;
    80000a1e:	557d                	li	a0,-1
    80000a20:	bfe5                	j	80000a18 <uartgetc+0x1e>

0000000080000a22 <uartintr>:
// handle a uart interrupt, raised because input has
// arrived, or the uart is ready for more output, or
// both. called from trap.c.
void
uartintr(void)
{
    80000a22:	1101                	addi	sp,sp,-32
    80000a24:	ec06                	sd	ra,24(sp)
    80000a26:	e822                	sd	s0,16(sp)
    80000a28:	e426                	sd	s1,8(sp)
    80000a2a:	1000                	addi	s0,sp,32
  // read and process incoming characters.
  while(1){
    int c = uartgetc();
    if(c == -1)
    80000a2c:	54fd                	li	s1,-1
    int c = uartgetc();
    80000a2e:	00000097          	auipc	ra,0x0
    80000a32:	fcc080e7          	jalr	-52(ra) # 800009fa <uartgetc>
    if(c == -1)
    80000a36:	00950763          	beq	a0,s1,80000a44 <uartintr+0x22>
      break;
    consoleintr(c);
    80000a3a:	00000097          	auipc	ra,0x0
    80000a3e:	894080e7          	jalr	-1900(ra) # 800002ce <consoleintr>
  while(1){
    80000a42:	b7f5                	j	80000a2e <uartintr+0xc>
  }

  // send buffered characters.
  acquire(&uart_tx_lock);
    80000a44:	00011497          	auipc	s1,0x11
    80000a48:	eb448493          	addi	s1,s1,-332 # 800118f8 <uart_tx_lock>
    80000a4c:	8526                	mv	a0,s1
    80000a4e:	00000097          	auipc	ra,0x0
    80000a52:	214080e7          	jalr	532(ra) # 80000c62 <acquire>
  uartstart();
    80000a56:	00000097          	auipc	ra,0x0
    80000a5a:	e24080e7          	jalr	-476(ra) # 8000087a <uartstart>
  release(&uart_tx_lock);
    80000a5e:	8526                	mv	a0,s1
    80000a60:	00000097          	auipc	ra,0x0
    80000a64:	2b6080e7          	jalr	694(ra) # 80000d16 <release>
}
    80000a68:	60e2                	ld	ra,24(sp)
    80000a6a:	6442                	ld	s0,16(sp)
    80000a6c:	64a2                	ld	s1,8(sp)
    80000a6e:	6105                	addi	sp,sp,32
    80000a70:	8082                	ret

0000000080000a72 <kfree>:
// which normally should have been returned by a
// call to kalloc().  (The exception is when
// initializing the allocator; see kinit above.)
void
kfree(void *pa)
{
    80000a72:	1101                	addi	sp,sp,-32
    80000a74:	ec06                	sd	ra,24(sp)
    80000a76:	e822                	sd	s0,16(sp)
    80000a78:	e426                	sd	s1,8(sp)
    80000a7a:	e04a                	sd	s2,0(sp)
    80000a7c:	1000                	addi	s0,sp,32
  struct run *r;

  if(((uint64)pa % PGSIZE) != 0 || (char*)pa < end || (uint64)pa >= PHYSTOP)
    80000a7e:	6785                	lui	a5,0x1
    80000a80:	17fd                	addi	a5,a5,-1
    80000a82:	8fe9                	and	a5,a5,a0
    80000a84:	ebb9                	bnez	a5,80000ada <kfree+0x68>
    80000a86:	84aa                	mv	s1,a0
    80000a88:	00025797          	auipc	a5,0x25
    80000a8c:	57878793          	addi	a5,a5,1400 # 80026000 <end>
    80000a90:	04f56563          	bltu	a0,a5,80000ada <kfree+0x68>
    80000a94:	47c5                	li	a5,17
    80000a96:	07ee                	slli	a5,a5,0x1b
    80000a98:	04f57163          	bleu	a5,a0,80000ada <kfree+0x68>
    panic("kfree");

  // Fill with junk to catch dangling refs.
  memset(pa, 1, PGSIZE);
    80000a9c:	6605                	lui	a2,0x1
    80000a9e:	4585                	li	a1,1
    80000aa0:	00000097          	auipc	ra,0x0
    80000aa4:	2be080e7          	jalr	702(ra) # 80000d5e <memset>

  r = (struct run*)pa;

  acquire(&kmem.lock);
    80000aa8:	00011917          	auipc	s2,0x11
    80000aac:	e8890913          	addi	s2,s2,-376 # 80011930 <kmem>
    80000ab0:	854a                	mv	a0,s2
    80000ab2:	00000097          	auipc	ra,0x0
    80000ab6:	1b0080e7          	jalr	432(ra) # 80000c62 <acquire>
  r->next = kmem.freelist;
    80000aba:	01893783          	ld	a5,24(s2)
    80000abe:	e09c                	sd	a5,0(s1)
  kmem.freelist = r;
    80000ac0:	00993c23          	sd	s1,24(s2)
  release(&kmem.lock);
    80000ac4:	854a                	mv	a0,s2
    80000ac6:	00000097          	auipc	ra,0x0
    80000aca:	250080e7          	jalr	592(ra) # 80000d16 <release>
}
    80000ace:	60e2                	ld	ra,24(sp)
    80000ad0:	6442                	ld	s0,16(sp)
    80000ad2:	64a2                	ld	s1,8(sp)
    80000ad4:	6902                	ld	s2,0(sp)
    80000ad6:	6105                	addi	sp,sp,32
    80000ad8:	8082                	ret
    panic("kfree");
    80000ada:	00007517          	auipc	a0,0x7
    80000ade:	58650513          	addi	a0,a0,1414 # 80008060 <digits+0x48>
    80000ae2:	00000097          	auipc	ra,0x0
    80000ae6:	a92080e7          	jalr	-1390(ra) # 80000574 <panic>

0000000080000aea <freerange>:
{
    80000aea:	7179                	addi	sp,sp,-48
    80000aec:	f406                	sd	ra,40(sp)
    80000aee:	f022                	sd	s0,32(sp)
    80000af0:	ec26                	sd	s1,24(sp)
    80000af2:	e84a                	sd	s2,16(sp)
    80000af4:	e44e                	sd	s3,8(sp)
    80000af6:	e052                	sd	s4,0(sp)
    80000af8:	1800                	addi	s0,sp,48
  p = (char*)PGROUNDUP((uint64)pa_start);
    80000afa:	6705                	lui	a4,0x1
    80000afc:	fff70793          	addi	a5,a4,-1 # fff <_entry-0x7ffff001>
    80000b00:	00f504b3          	add	s1,a0,a5
    80000b04:	77fd                	lui	a5,0xfffff
    80000b06:	8cfd                	and	s1,s1,a5
  for(; p + PGSIZE <= (char*)pa_end; p += PGSIZE)
    80000b08:	94ba                	add	s1,s1,a4
    80000b0a:	0095ee63          	bltu	a1,s1,80000b26 <freerange+0x3c>
    80000b0e:	892e                	mv	s2,a1
    kfree(p);
    80000b10:	7a7d                	lui	s4,0xfffff
  for(; p + PGSIZE <= (char*)pa_end; p += PGSIZE)
    80000b12:	6985                	lui	s3,0x1
    kfree(p);
    80000b14:	01448533          	add	a0,s1,s4
    80000b18:	00000097          	auipc	ra,0x0
    80000b1c:	f5a080e7          	jalr	-166(ra) # 80000a72 <kfree>
  for(; p + PGSIZE <= (char*)pa_end; p += PGSIZE)
    80000b20:	94ce                	add	s1,s1,s3
    80000b22:	fe9979e3          	bleu	s1,s2,80000b14 <freerange+0x2a>
}
    80000b26:	70a2                	ld	ra,40(sp)
    80000b28:	7402                	ld	s0,32(sp)
    80000b2a:	64e2                	ld	s1,24(sp)
    80000b2c:	6942                	ld	s2,16(sp)
    80000b2e:	69a2                	ld	s3,8(sp)
    80000b30:	6a02                	ld	s4,0(sp)
    80000b32:	6145                	addi	sp,sp,48
    80000b34:	8082                	ret

0000000080000b36 <kinit>:
{
    80000b36:	1141                	addi	sp,sp,-16
    80000b38:	e406                	sd	ra,8(sp)
    80000b3a:	e022                	sd	s0,0(sp)
    80000b3c:	0800                	addi	s0,sp,16
  initlock(&kmem.lock, "kmem");
    80000b3e:	00007597          	auipc	a1,0x7
    80000b42:	52a58593          	addi	a1,a1,1322 # 80008068 <digits+0x50>
    80000b46:	00011517          	auipc	a0,0x11
    80000b4a:	dea50513          	addi	a0,a0,-534 # 80011930 <kmem>
    80000b4e:	00000097          	auipc	ra,0x0
    80000b52:	084080e7          	jalr	132(ra) # 80000bd2 <initlock>
  freerange(end, (void*)PHYSTOP);
    80000b56:	45c5                	li	a1,17
    80000b58:	05ee                	slli	a1,a1,0x1b
    80000b5a:	00025517          	auipc	a0,0x25
    80000b5e:	4a650513          	addi	a0,a0,1190 # 80026000 <end>
    80000b62:	00000097          	auipc	ra,0x0
    80000b66:	f88080e7          	jalr	-120(ra) # 80000aea <freerange>
}
    80000b6a:	60a2                	ld	ra,8(sp)
    80000b6c:	6402                	ld	s0,0(sp)
    80000b6e:	0141                	addi	sp,sp,16
    80000b70:	8082                	ret

0000000080000b72 <kalloc>:
// Allocate one 4096-byte page of physical memory.
// Returns a pointer that the kernel can use.
// Returns 0 if the memory cannot be allocated.
void *
kalloc(void)
{
    80000b72:	1101                	addi	sp,sp,-32
    80000b74:	ec06                	sd	ra,24(sp)
    80000b76:	e822                	sd	s0,16(sp)
    80000b78:	e426                	sd	s1,8(sp)
    80000b7a:	1000                	addi	s0,sp,32
  struct run *r;

  acquire(&kmem.lock);
    80000b7c:	00011497          	auipc	s1,0x11
    80000b80:	db448493          	addi	s1,s1,-588 # 80011930 <kmem>
    80000b84:	8526                	mv	a0,s1
    80000b86:	00000097          	auipc	ra,0x0
    80000b8a:	0dc080e7          	jalr	220(ra) # 80000c62 <acquire>
  r = kmem.freelist;
    80000b8e:	6c84                	ld	s1,24(s1)
  if(r)
    80000b90:	c885                	beqz	s1,80000bc0 <kalloc+0x4e>
    kmem.freelist = r->next;
    80000b92:	609c                	ld	a5,0(s1)
    80000b94:	00011517          	auipc	a0,0x11
    80000b98:	d9c50513          	addi	a0,a0,-612 # 80011930 <kmem>
    80000b9c:	ed1c                	sd	a5,24(a0)
  release(&kmem.lock);
    80000b9e:	00000097          	auipc	ra,0x0
    80000ba2:	178080e7          	jalr	376(ra) # 80000d16 <release>

  if(r)
    memset((char*)r, 5, PGSIZE); // fill with junk
    80000ba6:	6605                	lui	a2,0x1
    80000ba8:	4595                	li	a1,5
    80000baa:	8526                	mv	a0,s1
    80000bac:	00000097          	auipc	ra,0x0
    80000bb0:	1b2080e7          	jalr	434(ra) # 80000d5e <memset>
  return (void*)r;
}
    80000bb4:	8526                	mv	a0,s1
    80000bb6:	60e2                	ld	ra,24(sp)
    80000bb8:	6442                	ld	s0,16(sp)
    80000bba:	64a2                	ld	s1,8(sp)
    80000bbc:	6105                	addi	sp,sp,32
    80000bbe:	8082                	ret
  release(&kmem.lock);
    80000bc0:	00011517          	auipc	a0,0x11
    80000bc4:	d7050513          	addi	a0,a0,-656 # 80011930 <kmem>
    80000bc8:	00000097          	auipc	ra,0x0
    80000bcc:	14e080e7          	jalr	334(ra) # 80000d16 <release>
  if(r)
    80000bd0:	b7d5                	j	80000bb4 <kalloc+0x42>

0000000080000bd2 <initlock>:
#include "proc.h"
#include "defs.h"

void
initlock(struct spinlock *lk, char *name)
{
    80000bd2:	1141                	addi	sp,sp,-16
    80000bd4:	e422                	sd	s0,8(sp)
    80000bd6:	0800                	addi	s0,sp,16
  lk->name = name;
    80000bd8:	e50c                	sd	a1,8(a0)
  lk->locked = 0;
    80000bda:	00052023          	sw	zero,0(a0)
  lk->cpu = 0;
    80000bde:	00053823          	sd	zero,16(a0)
}
    80000be2:	6422                	ld	s0,8(sp)
    80000be4:	0141                	addi	sp,sp,16
    80000be6:	8082                	ret

0000000080000be8 <holding>:
// Interrupts must be off.
int
holding(struct spinlock *lk)
{
  int r;
  r = (lk->locked && lk->cpu == mycpu());
    80000be8:	411c                	lw	a5,0(a0)
    80000bea:	e399                	bnez	a5,80000bf0 <holding+0x8>
    80000bec:	4501                	li	a0,0
  return r;
}
    80000bee:	8082                	ret
{
    80000bf0:	1101                	addi	sp,sp,-32
    80000bf2:	ec06                	sd	ra,24(sp)
    80000bf4:	e822                	sd	s0,16(sp)
    80000bf6:	e426                	sd	s1,8(sp)
    80000bf8:	1000                	addi	s0,sp,32
  r = (lk->locked && lk->cpu == mycpu());
    80000bfa:	6904                	ld	s1,16(a0)
    80000bfc:	00001097          	auipc	ra,0x1
    80000c00:	e80080e7          	jalr	-384(ra) # 80001a7c <mycpu>
    80000c04:	40a48533          	sub	a0,s1,a0
    80000c08:	00153513          	seqz	a0,a0
}
    80000c0c:	60e2                	ld	ra,24(sp)
    80000c0e:	6442                	ld	s0,16(sp)
    80000c10:	64a2                	ld	s1,8(sp)
    80000c12:	6105                	addi	sp,sp,32
    80000c14:	8082                	ret

0000000080000c16 <push_off>:
// it takes two pop_off()s to undo two push_off()s.  Also, if interrupts
// are initially off, then push_off, pop_off leaves them off.

void
push_off(void)
{
    80000c16:	1101                	addi	sp,sp,-32
    80000c18:	ec06                	sd	ra,24(sp)
    80000c1a:	e822                	sd	s0,16(sp)
    80000c1c:	e426                	sd	s1,8(sp)
    80000c1e:	1000                	addi	s0,sp,32
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80000c20:	100024f3          	csrr	s1,sstatus
    80000c24:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() & ~SSTATUS_SIE);
    80000c28:	9bf5                	andi	a5,a5,-3
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80000c2a:	10079073          	csrw	sstatus,a5
  int old = intr_get();

  intr_off();
  if(mycpu()->noff == 0)
    80000c2e:	00001097          	auipc	ra,0x1
    80000c32:	e4e080e7          	jalr	-434(ra) # 80001a7c <mycpu>
    80000c36:	5d3c                	lw	a5,120(a0)
    80000c38:	cf89                	beqz	a5,80000c52 <push_off+0x3c>
    mycpu()->intena = old;
  mycpu()->noff += 1;
    80000c3a:	00001097          	auipc	ra,0x1
    80000c3e:	e42080e7          	jalr	-446(ra) # 80001a7c <mycpu>
    80000c42:	5d3c                	lw	a5,120(a0)
    80000c44:	2785                	addiw	a5,a5,1
    80000c46:	dd3c                	sw	a5,120(a0)
}
    80000c48:	60e2                	ld	ra,24(sp)
    80000c4a:	6442                	ld	s0,16(sp)
    80000c4c:	64a2                	ld	s1,8(sp)
    80000c4e:	6105                	addi	sp,sp,32
    80000c50:	8082                	ret
    mycpu()->intena = old;
    80000c52:	00001097          	auipc	ra,0x1
    80000c56:	e2a080e7          	jalr	-470(ra) # 80001a7c <mycpu>
  return (x & SSTATUS_SIE) != 0;
    80000c5a:	8085                	srli	s1,s1,0x1
    80000c5c:	8885                	andi	s1,s1,1
    80000c5e:	dd64                	sw	s1,124(a0)
    80000c60:	bfe9                	j	80000c3a <push_off+0x24>

0000000080000c62 <acquire>:
{
    80000c62:	1101                	addi	sp,sp,-32
    80000c64:	ec06                	sd	ra,24(sp)
    80000c66:	e822                	sd	s0,16(sp)
    80000c68:	e426                	sd	s1,8(sp)
    80000c6a:	1000                	addi	s0,sp,32
    80000c6c:	84aa                	mv	s1,a0
  push_off(); // disable interrupts to avoid deadlock.
    80000c6e:	00000097          	auipc	ra,0x0
    80000c72:	fa8080e7          	jalr	-88(ra) # 80000c16 <push_off>
  if(holding(lk))
    80000c76:	8526                	mv	a0,s1
    80000c78:	00000097          	auipc	ra,0x0
    80000c7c:	f70080e7          	jalr	-144(ra) # 80000be8 <holding>
  while(__sync_lock_test_and_set(&lk->locked, 1) != 0)
    80000c80:	4705                	li	a4,1
  if(holding(lk))
    80000c82:	e115                	bnez	a0,80000ca6 <acquire+0x44>
  while(__sync_lock_test_and_set(&lk->locked, 1) != 0)
    80000c84:	87ba                	mv	a5,a4
    80000c86:	0cf4a7af          	amoswap.w.aq	a5,a5,(s1)
    80000c8a:	2781                	sext.w	a5,a5
    80000c8c:	ffe5                	bnez	a5,80000c84 <acquire+0x22>
  __sync_synchronize();
    80000c8e:	0ff0000f          	fence
  lk->cpu = mycpu();
    80000c92:	00001097          	auipc	ra,0x1
    80000c96:	dea080e7          	jalr	-534(ra) # 80001a7c <mycpu>
    80000c9a:	e888                	sd	a0,16(s1)
}
    80000c9c:	60e2                	ld	ra,24(sp)
    80000c9e:	6442                	ld	s0,16(sp)
    80000ca0:	64a2                	ld	s1,8(sp)
    80000ca2:	6105                	addi	sp,sp,32
    80000ca4:	8082                	ret
    panic("acquire");
    80000ca6:	00007517          	auipc	a0,0x7
    80000caa:	3ca50513          	addi	a0,a0,970 # 80008070 <digits+0x58>
    80000cae:	00000097          	auipc	ra,0x0
    80000cb2:	8c6080e7          	jalr	-1850(ra) # 80000574 <panic>

0000000080000cb6 <pop_off>:

void
pop_off(void)
{
    80000cb6:	1141                	addi	sp,sp,-16
    80000cb8:	e406                	sd	ra,8(sp)
    80000cba:	e022                	sd	s0,0(sp)
    80000cbc:	0800                	addi	s0,sp,16
  struct cpu *c = mycpu();
    80000cbe:	00001097          	auipc	ra,0x1
    80000cc2:	dbe080e7          	jalr	-578(ra) # 80001a7c <mycpu>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80000cc6:	100027f3          	csrr	a5,sstatus
  return (x & SSTATUS_SIE) != 0;
    80000cca:	8b89                	andi	a5,a5,2
  if(intr_get())
    80000ccc:	e78d                	bnez	a5,80000cf6 <pop_off+0x40>
    panic("pop_off - interruptible");
  if(c->noff < 1)
    80000cce:	5d3c                	lw	a5,120(a0)
    80000cd0:	02f05b63          	blez	a5,80000d06 <pop_off+0x50>
    panic("pop_off");
  c->noff -= 1;
    80000cd4:	37fd                	addiw	a5,a5,-1
    80000cd6:	0007871b          	sext.w	a4,a5
    80000cda:	dd3c                	sw	a5,120(a0)
  if(c->noff == 0 && c->intena)
    80000cdc:	eb09                	bnez	a4,80000cee <pop_off+0x38>
    80000cde:	5d7c                	lw	a5,124(a0)
    80000ce0:	c799                	beqz	a5,80000cee <pop_off+0x38>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80000ce2:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() | SSTATUS_SIE);
    80000ce6:	0027e793          	ori	a5,a5,2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80000cea:	10079073          	csrw	sstatus,a5
    intr_on();
}
    80000cee:	60a2                	ld	ra,8(sp)
    80000cf0:	6402                	ld	s0,0(sp)
    80000cf2:	0141                	addi	sp,sp,16
    80000cf4:	8082                	ret
    panic("pop_off - interruptible");
    80000cf6:	00007517          	auipc	a0,0x7
    80000cfa:	38250513          	addi	a0,a0,898 # 80008078 <digits+0x60>
    80000cfe:	00000097          	auipc	ra,0x0
    80000d02:	876080e7          	jalr	-1930(ra) # 80000574 <panic>
    panic("pop_off");
    80000d06:	00007517          	auipc	a0,0x7
    80000d0a:	38a50513          	addi	a0,a0,906 # 80008090 <digits+0x78>
    80000d0e:	00000097          	auipc	ra,0x0
    80000d12:	866080e7          	jalr	-1946(ra) # 80000574 <panic>

0000000080000d16 <release>:
{
    80000d16:	1101                	addi	sp,sp,-32
    80000d18:	ec06                	sd	ra,24(sp)
    80000d1a:	e822                	sd	s0,16(sp)
    80000d1c:	e426                	sd	s1,8(sp)
    80000d1e:	1000                	addi	s0,sp,32
    80000d20:	84aa                	mv	s1,a0
  if(!holding(lk))
    80000d22:	00000097          	auipc	ra,0x0
    80000d26:	ec6080e7          	jalr	-314(ra) # 80000be8 <holding>
    80000d2a:	c115                	beqz	a0,80000d4e <release+0x38>
  lk->cpu = 0;
    80000d2c:	0004b823          	sd	zero,16(s1)
  __sync_synchronize();
    80000d30:	0ff0000f          	fence
  __sync_lock_release(&lk->locked);
    80000d34:	0f50000f          	fence	iorw,ow
    80000d38:	0804a02f          	amoswap.w	zero,zero,(s1)
  pop_off();
    80000d3c:	00000097          	auipc	ra,0x0
    80000d40:	f7a080e7          	jalr	-134(ra) # 80000cb6 <pop_off>
}
    80000d44:	60e2                	ld	ra,24(sp)
    80000d46:	6442                	ld	s0,16(sp)
    80000d48:	64a2                	ld	s1,8(sp)
    80000d4a:	6105                	addi	sp,sp,32
    80000d4c:	8082                	ret
    panic("release");
    80000d4e:	00007517          	auipc	a0,0x7
    80000d52:	34a50513          	addi	a0,a0,842 # 80008098 <digits+0x80>
    80000d56:	00000097          	auipc	ra,0x0
    80000d5a:	81e080e7          	jalr	-2018(ra) # 80000574 <panic>

0000000080000d5e <memset>:
#include "types.h"

void*
memset(void *dst, int c, uint n)
{
    80000d5e:	1141                	addi	sp,sp,-16
    80000d60:	e422                	sd	s0,8(sp)
    80000d62:	0800                	addi	s0,sp,16
  char *cdst = (char *) dst;
  int i;
  for(i = 0; i < n; i++){
    80000d64:	ce09                	beqz	a2,80000d7e <memset+0x20>
    80000d66:	87aa                	mv	a5,a0
    80000d68:	fff6071b          	addiw	a4,a2,-1
    80000d6c:	1702                	slli	a4,a4,0x20
    80000d6e:	9301                	srli	a4,a4,0x20
    80000d70:	0705                	addi	a4,a4,1
    80000d72:	972a                	add	a4,a4,a0
    cdst[i] = c;
    80000d74:	00b78023          	sb	a1,0(a5) # fffffffffffff000 <end+0xffffffff7ffd9000>
  for(i = 0; i < n; i++){
    80000d78:	0785                	addi	a5,a5,1
    80000d7a:	fee79de3          	bne	a5,a4,80000d74 <memset+0x16>
  }
  return dst;
}
    80000d7e:	6422                	ld	s0,8(sp)
    80000d80:	0141                	addi	sp,sp,16
    80000d82:	8082                	ret

0000000080000d84 <memcmp>:

int
memcmp(const void *v1, const void *v2, uint n)
{
    80000d84:	1141                	addi	sp,sp,-16
    80000d86:	e422                	sd	s0,8(sp)
    80000d88:	0800                	addi	s0,sp,16
  const uchar *s1, *s2;

  s1 = v1;
  s2 = v2;
  while(n-- > 0){
    80000d8a:	ce15                	beqz	a2,80000dc6 <memcmp+0x42>
    80000d8c:	fff6069b          	addiw	a3,a2,-1
    if(*s1 != *s2)
    80000d90:	00054783          	lbu	a5,0(a0)
    80000d94:	0005c703          	lbu	a4,0(a1)
    80000d98:	02e79063          	bne	a5,a4,80000db8 <memcmp+0x34>
    80000d9c:	1682                	slli	a3,a3,0x20
    80000d9e:	9281                	srli	a3,a3,0x20
    80000da0:	0685                	addi	a3,a3,1
    80000da2:	96aa                	add	a3,a3,a0
      return *s1 - *s2;
    s1++, s2++;
    80000da4:	0505                	addi	a0,a0,1
    80000da6:	0585                	addi	a1,a1,1
  while(n-- > 0){
    80000da8:	00d50d63          	beq	a0,a3,80000dc2 <memcmp+0x3e>
    if(*s1 != *s2)
    80000dac:	00054783          	lbu	a5,0(a0)
    80000db0:	0005c703          	lbu	a4,0(a1)
    80000db4:	fee788e3          	beq	a5,a4,80000da4 <memcmp+0x20>
      return *s1 - *s2;
    80000db8:	40e7853b          	subw	a0,a5,a4
  }

  return 0;
}
    80000dbc:	6422                	ld	s0,8(sp)
    80000dbe:	0141                	addi	sp,sp,16
    80000dc0:	8082                	ret
  return 0;
    80000dc2:	4501                	li	a0,0
    80000dc4:	bfe5                	j	80000dbc <memcmp+0x38>
    80000dc6:	4501                	li	a0,0
    80000dc8:	bfd5                	j	80000dbc <memcmp+0x38>

0000000080000dca <memmove>:

void*
memmove(void *dst, const void *src, uint n)
{
    80000dca:	1141                	addi	sp,sp,-16
    80000dcc:	e422                	sd	s0,8(sp)
    80000dce:	0800                	addi	s0,sp,16
  const char *s;
  char *d;

  s = src;
  d = dst;
  if(s < d && s + n > d){
    80000dd0:	00a5f963          	bleu	a0,a1,80000de2 <memmove+0x18>
    80000dd4:	02061713          	slli	a4,a2,0x20
    80000dd8:	9301                	srli	a4,a4,0x20
    80000dda:	00e587b3          	add	a5,a1,a4
    80000dde:	02f56563          	bltu	a0,a5,80000e08 <memmove+0x3e>
    s += n;
    d += n;
    while(n-- > 0)
      *--d = *--s;
  } else
    while(n-- > 0)
    80000de2:	fff6069b          	addiw	a3,a2,-1
    80000de6:	ce11                	beqz	a2,80000e02 <memmove+0x38>
    80000de8:	1682                	slli	a3,a3,0x20
    80000dea:	9281                	srli	a3,a3,0x20
    80000dec:	0685                	addi	a3,a3,1
    80000dee:	96ae                	add	a3,a3,a1
    80000df0:	87aa                	mv	a5,a0
      *d++ = *s++;
    80000df2:	0585                	addi	a1,a1,1
    80000df4:	0785                	addi	a5,a5,1
    80000df6:	fff5c703          	lbu	a4,-1(a1)
    80000dfa:	fee78fa3          	sb	a4,-1(a5)
    while(n-- > 0)
    80000dfe:	fed59ae3          	bne	a1,a3,80000df2 <memmove+0x28>

  return dst;
}
    80000e02:	6422                	ld	s0,8(sp)
    80000e04:	0141                	addi	sp,sp,16
    80000e06:	8082                	ret
    d += n;
    80000e08:	972a                	add	a4,a4,a0
    while(n-- > 0)
    80000e0a:	fff6069b          	addiw	a3,a2,-1
    80000e0e:	da75                	beqz	a2,80000e02 <memmove+0x38>
    80000e10:	02069613          	slli	a2,a3,0x20
    80000e14:	9201                	srli	a2,a2,0x20
    80000e16:	fff64613          	not	a2,a2
    80000e1a:	963e                	add	a2,a2,a5
      *--d = *--s;
    80000e1c:	17fd                	addi	a5,a5,-1
    80000e1e:	177d                	addi	a4,a4,-1
    80000e20:	0007c683          	lbu	a3,0(a5)
    80000e24:	00d70023          	sb	a3,0(a4)
    while(n-- > 0)
    80000e28:	fef61ae3          	bne	a2,a5,80000e1c <memmove+0x52>
    80000e2c:	bfd9                	j	80000e02 <memmove+0x38>

0000000080000e2e <memcpy>:

// memcpy exists to placate GCC.  Use memmove.
void*
memcpy(void *dst, const void *src, uint n)
{
    80000e2e:	1141                	addi	sp,sp,-16
    80000e30:	e406                	sd	ra,8(sp)
    80000e32:	e022                	sd	s0,0(sp)
    80000e34:	0800                	addi	s0,sp,16
  return memmove(dst, src, n);
    80000e36:	00000097          	auipc	ra,0x0
    80000e3a:	f94080e7          	jalr	-108(ra) # 80000dca <memmove>
}
    80000e3e:	60a2                	ld	ra,8(sp)
    80000e40:	6402                	ld	s0,0(sp)
    80000e42:	0141                	addi	sp,sp,16
    80000e44:	8082                	ret

0000000080000e46 <strncmp>:

int
strncmp(const char *p, const char *q, uint n)
{
    80000e46:	1141                	addi	sp,sp,-16
    80000e48:	e422                	sd	s0,8(sp)
    80000e4a:	0800                	addi	s0,sp,16
  while(n > 0 && *p && *p == *q)
    80000e4c:	c229                	beqz	a2,80000e8e <strncmp+0x48>
    80000e4e:	00054783          	lbu	a5,0(a0)
    80000e52:	c795                	beqz	a5,80000e7e <strncmp+0x38>
    80000e54:	0005c703          	lbu	a4,0(a1)
    80000e58:	02f71363          	bne	a4,a5,80000e7e <strncmp+0x38>
    80000e5c:	fff6071b          	addiw	a4,a2,-1
    80000e60:	1702                	slli	a4,a4,0x20
    80000e62:	9301                	srli	a4,a4,0x20
    80000e64:	0705                	addi	a4,a4,1
    80000e66:	972a                	add	a4,a4,a0
    n--, p++, q++;
    80000e68:	0505                	addi	a0,a0,1
    80000e6a:	0585                	addi	a1,a1,1
  while(n > 0 && *p && *p == *q)
    80000e6c:	02e50363          	beq	a0,a4,80000e92 <strncmp+0x4c>
    80000e70:	00054783          	lbu	a5,0(a0)
    80000e74:	c789                	beqz	a5,80000e7e <strncmp+0x38>
    80000e76:	0005c683          	lbu	a3,0(a1)
    80000e7a:	fef687e3          	beq	a3,a5,80000e68 <strncmp+0x22>
  if(n == 0)
    return 0;
  return (uchar)*p - (uchar)*q;
    80000e7e:	00054503          	lbu	a0,0(a0)
    80000e82:	0005c783          	lbu	a5,0(a1)
    80000e86:	9d1d                	subw	a0,a0,a5
}
    80000e88:	6422                	ld	s0,8(sp)
    80000e8a:	0141                	addi	sp,sp,16
    80000e8c:	8082                	ret
    return 0;
    80000e8e:	4501                	li	a0,0
    80000e90:	bfe5                	j	80000e88 <strncmp+0x42>
    80000e92:	4501                	li	a0,0
    80000e94:	bfd5                	j	80000e88 <strncmp+0x42>

0000000080000e96 <strncpy>:

char*
strncpy(char *s, const char *t, int n)
{
    80000e96:	1141                	addi	sp,sp,-16
    80000e98:	e422                	sd	s0,8(sp)
    80000e9a:	0800                	addi	s0,sp,16
  char *os;

  os = s;
  while(n-- > 0 && (*s++ = *t++) != 0)
    80000e9c:	872a                	mv	a4,a0
    80000e9e:	a011                	j	80000ea2 <strncpy+0xc>
    80000ea0:	8636                	mv	a2,a3
    80000ea2:	fff6069b          	addiw	a3,a2,-1
    80000ea6:	00c05963          	blez	a2,80000eb8 <strncpy+0x22>
    80000eaa:	0705                	addi	a4,a4,1
    80000eac:	0005c783          	lbu	a5,0(a1)
    80000eb0:	fef70fa3          	sb	a5,-1(a4)
    80000eb4:	0585                	addi	a1,a1,1
    80000eb6:	f7ed                	bnez	a5,80000ea0 <strncpy+0xa>
    ;
  while(n-- > 0)
    80000eb8:	00d05c63          	blez	a3,80000ed0 <strncpy+0x3a>
    80000ebc:	86ba                	mv	a3,a4
    *s++ = 0;
    80000ebe:	0685                	addi	a3,a3,1
    80000ec0:	fe068fa3          	sb	zero,-1(a3)
  while(n-- > 0)
    80000ec4:	fff6c793          	not	a5,a3
    80000ec8:	9fb9                	addw	a5,a5,a4
    80000eca:	9fb1                	addw	a5,a5,a2
    80000ecc:	fef049e3          	bgtz	a5,80000ebe <strncpy+0x28>
  return os;
}
    80000ed0:	6422                	ld	s0,8(sp)
    80000ed2:	0141                	addi	sp,sp,16
    80000ed4:	8082                	ret

0000000080000ed6 <safestrcpy>:

// Like strncpy but guaranteed to NUL-terminate.
char*
safestrcpy(char *s, const char *t, int n)
{
    80000ed6:	1141                	addi	sp,sp,-16
    80000ed8:	e422                	sd	s0,8(sp)
    80000eda:	0800                	addi	s0,sp,16
  char *os;

  os = s;
  if(n <= 0)
    80000edc:	02c05363          	blez	a2,80000f02 <safestrcpy+0x2c>
    80000ee0:	fff6069b          	addiw	a3,a2,-1
    80000ee4:	1682                	slli	a3,a3,0x20
    80000ee6:	9281                	srli	a3,a3,0x20
    80000ee8:	96ae                	add	a3,a3,a1
    80000eea:	87aa                	mv	a5,a0
    return os;
  while(--n > 0 && (*s++ = *t++) != 0)
    80000eec:	00d58963          	beq	a1,a3,80000efe <safestrcpy+0x28>
    80000ef0:	0585                	addi	a1,a1,1
    80000ef2:	0785                	addi	a5,a5,1
    80000ef4:	fff5c703          	lbu	a4,-1(a1)
    80000ef8:	fee78fa3          	sb	a4,-1(a5)
    80000efc:	fb65                	bnez	a4,80000eec <safestrcpy+0x16>
    ;
  *s = 0;
    80000efe:	00078023          	sb	zero,0(a5)
  return os;
}
    80000f02:	6422                	ld	s0,8(sp)
    80000f04:	0141                	addi	sp,sp,16
    80000f06:	8082                	ret

0000000080000f08 <strlen>:

int
strlen(const char *s)
{
    80000f08:	1141                	addi	sp,sp,-16
    80000f0a:	e422                	sd	s0,8(sp)
    80000f0c:	0800                	addi	s0,sp,16
  int n;

  for(n = 0; s[n]; n++)
    80000f0e:	00054783          	lbu	a5,0(a0)
    80000f12:	cf91                	beqz	a5,80000f2e <strlen+0x26>
    80000f14:	0505                	addi	a0,a0,1
    80000f16:	87aa                	mv	a5,a0
    80000f18:	4685                	li	a3,1
    80000f1a:	9e89                	subw	a3,a3,a0
    80000f1c:	00f6853b          	addw	a0,a3,a5
    80000f20:	0785                	addi	a5,a5,1
    80000f22:	fff7c703          	lbu	a4,-1(a5)
    80000f26:	fb7d                	bnez	a4,80000f1c <strlen+0x14>
    ;
  return n;
}
    80000f28:	6422                	ld	s0,8(sp)
    80000f2a:	0141                	addi	sp,sp,16
    80000f2c:	8082                	ret
  for(n = 0; s[n]; n++)
    80000f2e:	4501                	li	a0,0
    80000f30:	bfe5                	j	80000f28 <strlen+0x20>

0000000080000f32 <main>:
volatile static int started = 0;

// start() jumps here in supervisor mode on all CPUs.
void
main()
{
    80000f32:	1141                	addi	sp,sp,-16
    80000f34:	e406                	sd	ra,8(sp)
    80000f36:	e022                	sd	s0,0(sp)
    80000f38:	0800                	addi	s0,sp,16
  if(cpuid() == 0){
    80000f3a:	00001097          	auipc	ra,0x1
    80000f3e:	b32080e7          	jalr	-1230(ra) # 80001a6c <cpuid>
    virtio_disk_init(); // emulated hard disk
    userinit();      // first user process
    __sync_synchronize();
    started = 1;
  } else {
    while(started == 0)
    80000f42:	00008717          	auipc	a4,0x8
    80000f46:	0ca70713          	addi	a4,a4,202 # 8000900c <started>
  if(cpuid() == 0){
    80000f4a:	c139                	beqz	a0,80000f90 <main+0x5e>
    while(started == 0)
    80000f4c:	431c                	lw	a5,0(a4)
    80000f4e:	2781                	sext.w	a5,a5
    80000f50:	dff5                	beqz	a5,80000f4c <main+0x1a>
      ;
    __sync_synchronize();
    80000f52:	0ff0000f          	fence
    printf("hart %d starting\n", cpuid());
    80000f56:	00001097          	auipc	ra,0x1
    80000f5a:	b16080e7          	jalr	-1258(ra) # 80001a6c <cpuid>
    80000f5e:	85aa                	mv	a1,a0
    80000f60:	00007517          	auipc	a0,0x7
    80000f64:	15850513          	addi	a0,a0,344 # 800080b8 <digits+0xa0>
    80000f68:	fffff097          	auipc	ra,0xfffff
    80000f6c:	656080e7          	jalr	1622(ra) # 800005be <printf>
    kvminithart();    // turn on paging
    80000f70:	00000097          	auipc	ra,0x0
    80000f74:	0d8080e7          	jalr	216(ra) # 80001048 <kvminithart>
    trapinithart();   // install kernel trap vector
    80000f78:	00001097          	auipc	ra,0x1
    80000f7c:	78a080e7          	jalr	1930(ra) # 80002702 <trapinithart>
    plicinithart();   // ask PLIC for device interrupts
    80000f80:	00005097          	auipc	ra,0x5
    80000f84:	ea0080e7          	jalr	-352(ra) # 80005e20 <plicinithart>
  }

  scheduler();        
    80000f88:	00001097          	auipc	ra,0x1
    80000f8c:	046080e7          	jalr	70(ra) # 80001fce <scheduler>
    consoleinit();
    80000f90:	fffff097          	auipc	ra,0xfffff
    80000f94:	4f2080e7          	jalr	1266(ra) # 80000482 <consoleinit>
    printfinit();
    80000f98:	00000097          	auipc	ra,0x0
    80000f9c:	80c080e7          	jalr	-2036(ra) # 800007a4 <printfinit>
    printf("\n");
    80000fa0:	00007517          	auipc	a0,0x7
    80000fa4:	12850513          	addi	a0,a0,296 # 800080c8 <digits+0xb0>
    80000fa8:	fffff097          	auipc	ra,0xfffff
    80000fac:	616080e7          	jalr	1558(ra) # 800005be <printf>
    printf("xv6 kernel is booting\n");
    80000fb0:	00007517          	auipc	a0,0x7
    80000fb4:	0f050513          	addi	a0,a0,240 # 800080a0 <digits+0x88>
    80000fb8:	fffff097          	auipc	ra,0xfffff
    80000fbc:	606080e7          	jalr	1542(ra) # 800005be <printf>
    printf("\n");
    80000fc0:	00007517          	auipc	a0,0x7
    80000fc4:	10850513          	addi	a0,a0,264 # 800080c8 <digits+0xb0>
    80000fc8:	fffff097          	auipc	ra,0xfffff
    80000fcc:	5f6080e7          	jalr	1526(ra) # 800005be <printf>
    kinit();         // physical page allocator
    80000fd0:	00000097          	auipc	ra,0x0
    80000fd4:	b66080e7          	jalr	-1178(ra) # 80000b36 <kinit>
    kvminit();       // create kernel page table
    80000fd8:	00000097          	auipc	ra,0x0
    80000fdc:	30a080e7          	jalr	778(ra) # 800012e2 <kvminit>
    kvminithart();   // turn on paging
    80000fe0:	00000097          	auipc	ra,0x0
    80000fe4:	068080e7          	jalr	104(ra) # 80001048 <kvminithart>
    procinit();      // process table
    80000fe8:	00001097          	auipc	ra,0x1
    80000fec:	9b4080e7          	jalr	-1612(ra) # 8000199c <procinit>
    trapinit();      // trap vectors
    80000ff0:	00001097          	auipc	ra,0x1
    80000ff4:	6ea080e7          	jalr	1770(ra) # 800026da <trapinit>
    trapinithart();  // install kernel trap vector
    80000ff8:	00001097          	auipc	ra,0x1
    80000ffc:	70a080e7          	jalr	1802(ra) # 80002702 <trapinithart>
    plicinit();      // set up interrupt controller
    80001000:	00005097          	auipc	ra,0x5
    80001004:	e0a080e7          	jalr	-502(ra) # 80005e0a <plicinit>
    plicinithart();  // ask PLIC for device interrupts
    80001008:	00005097          	auipc	ra,0x5
    8000100c:	e18080e7          	jalr	-488(ra) # 80005e20 <plicinithart>
    binit();         // buffer cache
    80001010:	00002097          	auipc	ra,0x2
    80001014:	eea080e7          	jalr	-278(ra) # 80002efa <binit>
    iinit();         // inode cache
    80001018:	00002097          	auipc	ra,0x2
    8000101c:	5bc080e7          	jalr	1468(ra) # 800035d4 <iinit>
    fileinit();      // file table
    80001020:	00003097          	auipc	ra,0x3
    80001024:	586080e7          	jalr	1414(ra) # 800045a6 <fileinit>
    virtio_disk_init(); // emulated hard disk
    80001028:	00005097          	auipc	ra,0x5
    8000102c:	f02080e7          	jalr	-254(ra) # 80005f2a <virtio_disk_init>
    userinit();      // first user process
    80001030:	00001097          	auipc	ra,0x1
    80001034:	d34080e7          	jalr	-716(ra) # 80001d64 <userinit>
    __sync_synchronize();
    80001038:	0ff0000f          	fence
    started = 1;
    8000103c:	4785                	li	a5,1
    8000103e:	00008717          	auipc	a4,0x8
    80001042:	fcf72723          	sw	a5,-50(a4) # 8000900c <started>
    80001046:	b789                	j	80000f88 <main+0x56>

0000000080001048 <kvminithart>:

// Switch h/w page table register to the kernel's page table,
// and enable paging.
void
kvminithart()
{
    80001048:	1141                	addi	sp,sp,-16
    8000104a:	e422                	sd	s0,8(sp)
    8000104c:	0800                	addi	s0,sp,16
  w_satp(MAKE_SATP(kernel_pagetable));
    8000104e:	00008797          	auipc	a5,0x8
    80001052:	fc278793          	addi	a5,a5,-62 # 80009010 <kernel_pagetable>
    80001056:	639c                	ld	a5,0(a5)
    80001058:	83b1                	srli	a5,a5,0xc
    8000105a:	577d                	li	a4,-1
    8000105c:	177e                	slli	a4,a4,0x3f
    8000105e:	8fd9                	or	a5,a5,a4
  asm volatile("csrw satp, %0" : : "r" (x));
    80001060:	18079073          	csrw	satp,a5
// flush the TLB.
static inline void
sfence_vma()
{
  // the zero, zero means flush all TLB entries.
  asm volatile("sfence.vma zero, zero");
    80001064:	12000073          	sfence.vma
  sfence_vma();
}
    80001068:	6422                	ld	s0,8(sp)
    8000106a:	0141                	addi	sp,sp,16
    8000106c:	8082                	ret

000000008000106e <walk>:
//   21..29 -- 9 bits of level-1 index.
//   12..20 -- 9 bits of level-0 index.
//    0..11 -- 12 bits of byte offset within the page.
pte_t *
walk(pagetable_t pagetable, uint64 va, int alloc)
{
    8000106e:	7139                	addi	sp,sp,-64
    80001070:	fc06                	sd	ra,56(sp)
    80001072:	f822                	sd	s0,48(sp)
    80001074:	f426                	sd	s1,40(sp)
    80001076:	f04a                	sd	s2,32(sp)
    80001078:	ec4e                	sd	s3,24(sp)
    8000107a:	e852                	sd	s4,16(sp)
    8000107c:	e456                	sd	s5,8(sp)
    8000107e:	e05a                	sd	s6,0(sp)
    80001080:	0080                	addi	s0,sp,64
    80001082:	84aa                	mv	s1,a0
    80001084:	89ae                	mv	s3,a1
    80001086:	8b32                	mv	s6,a2
  if(va >= MAXVA)
    80001088:	57fd                	li	a5,-1
    8000108a:	83e9                	srli	a5,a5,0x1a
    8000108c:	4a79                	li	s4,30
    panic("walk");

  for(int level = 2; level > 0; level--) {
    8000108e:	4ab1                	li	s5,12
  if(va >= MAXVA)
    80001090:	04b7f263          	bleu	a1,a5,800010d4 <walk+0x66>
    panic("walk");
    80001094:	00007517          	auipc	a0,0x7
    80001098:	03c50513          	addi	a0,a0,60 # 800080d0 <digits+0xb8>
    8000109c:	fffff097          	auipc	ra,0xfffff
    800010a0:	4d8080e7          	jalr	1240(ra) # 80000574 <panic>
    pte_t *pte = &pagetable[PX(level, va)];
    if(*pte & PTE_V) {
      pagetable = (pagetable_t)PTE2PA(*pte);
    } else {
      if(!alloc || (pagetable = (pde_t*)kalloc()) == 0)
    800010a4:	060b0663          	beqz	s6,80001110 <walk+0xa2>
    800010a8:	00000097          	auipc	ra,0x0
    800010ac:	aca080e7          	jalr	-1334(ra) # 80000b72 <kalloc>
    800010b0:	84aa                	mv	s1,a0
    800010b2:	c529                	beqz	a0,800010fc <walk+0x8e>
        return 0;
      memset(pagetable, 0, PGSIZE);
    800010b4:	6605                	lui	a2,0x1
    800010b6:	4581                	li	a1,0
    800010b8:	00000097          	auipc	ra,0x0
    800010bc:	ca6080e7          	jalr	-858(ra) # 80000d5e <memset>
      *pte = PA2PTE(pagetable) | PTE_V;
    800010c0:	00c4d793          	srli	a5,s1,0xc
    800010c4:	07aa                	slli	a5,a5,0xa
    800010c6:	0017e793          	ori	a5,a5,1
    800010ca:	00f93023          	sd	a5,0(s2)
  for(int level = 2; level > 0; level--) {
    800010ce:	3a5d                	addiw	s4,s4,-9
    800010d0:	035a0063          	beq	s4,s5,800010f0 <walk+0x82>
    pte_t *pte = &pagetable[PX(level, va)];
    800010d4:	0149d933          	srl	s2,s3,s4
    800010d8:	1ff97913          	andi	s2,s2,511
    800010dc:	090e                	slli	s2,s2,0x3
    800010de:	9926                	add	s2,s2,s1
    if(*pte & PTE_V) {
    800010e0:	00093483          	ld	s1,0(s2)
    800010e4:	0014f793          	andi	a5,s1,1
    800010e8:	dfd5                	beqz	a5,800010a4 <walk+0x36>
      pagetable = (pagetable_t)PTE2PA(*pte);
    800010ea:	80a9                	srli	s1,s1,0xa
    800010ec:	04b2                	slli	s1,s1,0xc
    800010ee:	b7c5                	j	800010ce <walk+0x60>
    }
  }
  return &pagetable[PX(0, va)];
    800010f0:	00c9d513          	srli	a0,s3,0xc
    800010f4:	1ff57513          	andi	a0,a0,511
    800010f8:	050e                	slli	a0,a0,0x3
    800010fa:	9526                	add	a0,a0,s1
}
    800010fc:	70e2                	ld	ra,56(sp)
    800010fe:	7442                	ld	s0,48(sp)
    80001100:	74a2                	ld	s1,40(sp)
    80001102:	7902                	ld	s2,32(sp)
    80001104:	69e2                	ld	s3,24(sp)
    80001106:	6a42                	ld	s4,16(sp)
    80001108:	6aa2                	ld	s5,8(sp)
    8000110a:	6b02                	ld	s6,0(sp)
    8000110c:	6121                	addi	sp,sp,64
    8000110e:	8082                	ret
        return 0;
    80001110:	4501                	li	a0,0
    80001112:	b7ed                	j	800010fc <walk+0x8e>

0000000080001114 <kvmpa>:
// a physical address. only needed for
// addresses on the stack.
// assumes va is page aligned.
uint64
kvmpa(uint64 va)
{
    80001114:	1101                	addi	sp,sp,-32
    80001116:	ec06                	sd	ra,24(sp)
    80001118:	e822                	sd	s0,16(sp)
    8000111a:	e426                	sd	s1,8(sp)
    8000111c:	1000                	addi	s0,sp,32
    8000111e:	85aa                	mv	a1,a0
  uint64 off = va % PGSIZE;
    80001120:	6785                	lui	a5,0x1
    80001122:	17fd                	addi	a5,a5,-1
    80001124:	00f574b3          	and	s1,a0,a5
  pte_t *pte;
  uint64 pa;
  
  pte = walk(kernel_pagetable, va, 0);
    80001128:	4601                	li	a2,0
    8000112a:	00008797          	auipc	a5,0x8
    8000112e:	ee678793          	addi	a5,a5,-282 # 80009010 <kernel_pagetable>
    80001132:	6388                	ld	a0,0(a5)
    80001134:	00000097          	auipc	ra,0x0
    80001138:	f3a080e7          	jalr	-198(ra) # 8000106e <walk>
  if(pte == 0)
    8000113c:	cd09                	beqz	a0,80001156 <kvmpa+0x42>
    panic("kvmpa");
  if((*pte & PTE_V) == 0)
    8000113e:	6108                	ld	a0,0(a0)
    80001140:	00157793          	andi	a5,a0,1
    80001144:	c38d                	beqz	a5,80001166 <kvmpa+0x52>
    panic("kvmpa");
  pa = PTE2PA(*pte);
    80001146:	8129                	srli	a0,a0,0xa
    80001148:	0532                	slli	a0,a0,0xc
  return pa+off;
}
    8000114a:	9526                	add	a0,a0,s1
    8000114c:	60e2                	ld	ra,24(sp)
    8000114e:	6442                	ld	s0,16(sp)
    80001150:	64a2                	ld	s1,8(sp)
    80001152:	6105                	addi	sp,sp,32
    80001154:	8082                	ret
    panic("kvmpa");
    80001156:	00007517          	auipc	a0,0x7
    8000115a:	f8250513          	addi	a0,a0,-126 # 800080d8 <digits+0xc0>
    8000115e:	fffff097          	auipc	ra,0xfffff
    80001162:	416080e7          	jalr	1046(ra) # 80000574 <panic>
    panic("kvmpa");
    80001166:	00007517          	auipc	a0,0x7
    8000116a:	f7250513          	addi	a0,a0,-142 # 800080d8 <digits+0xc0>
    8000116e:	fffff097          	auipc	ra,0xfffff
    80001172:	406080e7          	jalr	1030(ra) # 80000574 <panic>

0000000080001176 <mappages>:
// physical addresses starting at pa. va and size might not
// be page-aligned. Returns 0 on success, -1 if walk() couldn't
// allocate a needed page-table page.
int
mappages(pagetable_t pagetable, uint64 va, uint64 size, uint64 pa, int perm)
{
    80001176:	715d                	addi	sp,sp,-80
    80001178:	e486                	sd	ra,72(sp)
    8000117a:	e0a2                	sd	s0,64(sp)
    8000117c:	fc26                	sd	s1,56(sp)
    8000117e:	f84a                	sd	s2,48(sp)
    80001180:	f44e                	sd	s3,40(sp)
    80001182:	f052                	sd	s4,32(sp)
    80001184:	ec56                	sd	s5,24(sp)
    80001186:	e85a                	sd	s6,16(sp)
    80001188:	e45e                	sd	s7,8(sp)
    8000118a:	0880                	addi	s0,sp,80
    8000118c:	8aaa                	mv	s5,a0
    8000118e:	8b3a                	mv	s6,a4
  uint64 a, last;
  pte_t *pte;

  a = PGROUNDDOWN(va);
    80001190:	79fd                	lui	s3,0xfffff
    80001192:	0135fa33          	and	s4,a1,s3
  last = PGROUNDDOWN(va + size - 1);
    80001196:	167d                	addi	a2,a2,-1
    80001198:	962e                	add	a2,a2,a1
    8000119a:	013679b3          	and	s3,a2,s3
  a = PGROUNDDOWN(va);
    8000119e:	8952                	mv	s2,s4
    800011a0:	41468a33          	sub	s4,a3,s4
    if(*pte & PTE_V)
      panic("remap");
    *pte = PA2PTE(pa) | perm | PTE_V;
    if(a == last)
      break;
    a += PGSIZE;
    800011a4:	6b85                	lui	s7,0x1
    800011a6:	a811                	j	800011ba <mappages+0x44>
      panic("remap");
    800011a8:	00007517          	auipc	a0,0x7
    800011ac:	f3850513          	addi	a0,a0,-200 # 800080e0 <digits+0xc8>
    800011b0:	fffff097          	auipc	ra,0xfffff
    800011b4:	3c4080e7          	jalr	964(ra) # 80000574 <panic>
    a += PGSIZE;
    800011b8:	995e                	add	s2,s2,s7
  for(;;){
    800011ba:	012a04b3          	add	s1,s4,s2
    if((pte = walk(pagetable, a, 1)) == 0)
    800011be:	4605                	li	a2,1
    800011c0:	85ca                	mv	a1,s2
    800011c2:	8556                	mv	a0,s5
    800011c4:	00000097          	auipc	ra,0x0
    800011c8:	eaa080e7          	jalr	-342(ra) # 8000106e <walk>
    800011cc:	cd19                	beqz	a0,800011ea <mappages+0x74>
    if(*pte & PTE_V)
    800011ce:	611c                	ld	a5,0(a0)
    800011d0:	8b85                	andi	a5,a5,1
    800011d2:	fbf9                	bnez	a5,800011a8 <mappages+0x32>
    *pte = PA2PTE(pa) | perm | PTE_V;
    800011d4:	80b1                	srli	s1,s1,0xc
    800011d6:	04aa                	slli	s1,s1,0xa
    800011d8:	0164e4b3          	or	s1,s1,s6
    800011dc:	0014e493          	ori	s1,s1,1
    800011e0:	e104                	sd	s1,0(a0)
    if(a == last)
    800011e2:	fd391be3          	bne	s2,s3,800011b8 <mappages+0x42>
    pa += PGSIZE;
  }
  return 0;
    800011e6:	4501                	li	a0,0
    800011e8:	a011                	j	800011ec <mappages+0x76>
      return -1;
    800011ea:	557d                	li	a0,-1
}
    800011ec:	60a6                	ld	ra,72(sp)
    800011ee:	6406                	ld	s0,64(sp)
    800011f0:	74e2                	ld	s1,56(sp)
    800011f2:	7942                	ld	s2,48(sp)
    800011f4:	79a2                	ld	s3,40(sp)
    800011f6:	7a02                	ld	s4,32(sp)
    800011f8:	6ae2                	ld	s5,24(sp)
    800011fa:	6b42                	ld	s6,16(sp)
    800011fc:	6ba2                	ld	s7,8(sp)
    800011fe:	6161                	addi	sp,sp,80
    80001200:	8082                	ret

0000000080001202 <walkaddr>:
{
    80001202:	7179                	addi	sp,sp,-48
    80001204:	f406                	sd	ra,40(sp)
    80001206:	f022                	sd	s0,32(sp)
    80001208:	ec26                	sd	s1,24(sp)
    8000120a:	e84a                	sd	s2,16(sp)
    8000120c:	e44e                	sd	s3,8(sp)
    8000120e:	e052                	sd	s4,0(sp)
    80001210:	1800                	addi	s0,sp,48
  if(va >= MAXVA )
    80001212:	57fd                	li	a5,-1
    80001214:	83e9                	srli	a5,a5,0x1a
    return 0;
    80001216:	4481                	li	s1,0
  if(va >= MAXVA )
    80001218:	00b7fb63          	bleu	a1,a5,8000122e <walkaddr+0x2c>
}
    8000121c:	8526                	mv	a0,s1
    8000121e:	70a2                	ld	ra,40(sp)
    80001220:	7402                	ld	s0,32(sp)
    80001222:	64e2                	ld	s1,24(sp)
    80001224:	6942                	ld	s2,16(sp)
    80001226:	69a2                	ld	s3,8(sp)
    80001228:	6a02                	ld	s4,0(sp)
    8000122a:	6145                	addi	sp,sp,48
    8000122c:	8082                	ret
    8000122e:	892e                	mv	s2,a1
  pte = walk(pagetable, va, 0);
    80001230:	4601                	li	a2,0
    80001232:	00000097          	auipc	ra,0x0
    80001236:	e3c080e7          	jalr	-452(ra) # 8000106e <walk>
  if(pte == 0 || (*pte & PTE_V) == 0) {
    8000123a:	c509                	beqz	a0,80001244 <walkaddr+0x42>
    8000123c:	611c                	ld	a5,0(a0)
    8000123e:	0017f713          	andi	a4,a5,1
    80001242:	ef21                	bnez	a4,8000129a <walkaddr+0x98>
    struct proc *p = myproc();
    80001244:	00001097          	auipc	ra,0x1
    80001248:	854080e7          	jalr	-1964(ra) # 80001a98 <myproc>
    8000124c:	89aa                	mv	s3,a0
    if(va >= p->sz || va < PGROUNDUP(p->trapframe->sp)) return 0;
    8000124e:	653c                	ld	a5,72(a0)
    80001250:	4481                	li	s1,0
    80001252:	fcf975e3          	bleu	a5,s2,8000121c <walkaddr+0x1a>
    80001256:	6d3c                	ld	a5,88(a0)
    80001258:	7b9c                	ld	a5,48(a5)
    8000125a:	6705                	lui	a4,0x1
    8000125c:	177d                	addi	a4,a4,-1
    8000125e:	97ba                	add	a5,a5,a4
    80001260:	777d                	lui	a4,0xfffff
    80001262:	8ff9                	and	a5,a5,a4
    80001264:	faf96ce3          	bltu	s2,a5,8000121c <walkaddr+0x1a>
    pa = (uint64)kalloc();
    80001268:	00000097          	auipc	ra,0x0
    8000126c:	90a080e7          	jalr	-1782(ra) # 80000b72 <kalloc>
    80001270:	8a2a                	mv	s4,a0
    if (pa == 0) return 0;
    80001272:	d54d                	beqz	a0,8000121c <walkaddr+0x1a>
    pa = (uint64)kalloc();
    80001274:	84aa                	mv	s1,a0
    if (mappages(p->pagetable, va, PGSIZE, pa, PTE_W|PTE_R|PTE_U|PTE_X) != 0) {
    80001276:	4779                	li	a4,30
    80001278:	86aa                	mv	a3,a0
    8000127a:	6605                	lui	a2,0x1
    8000127c:	85ca                	mv	a1,s2
    8000127e:	0509b503          	ld	a0,80(s3) # fffffffffffff050 <end+0xffffffff7ffd9050>
    80001282:	00000097          	auipc	ra,0x0
    80001286:	ef4080e7          	jalr	-268(ra) # 80001176 <mappages>
    8000128a:	d949                	beqz	a0,8000121c <walkaddr+0x1a>
      kfree((void*)pa);
    8000128c:	8552                	mv	a0,s4
    8000128e:	fffff097          	auipc	ra,0xfffff
    80001292:	7e4080e7          	jalr	2020(ra) # 80000a72 <kfree>
      return 0;
    80001296:	4481                	li	s1,0
    80001298:	b751                	j	8000121c <walkaddr+0x1a>
  if((*pte & PTE_U) == 0)
    8000129a:	0107f493          	andi	s1,a5,16
    8000129e:	dcbd                	beqz	s1,8000121c <walkaddr+0x1a>
  pa = PTE2PA(*pte);
    800012a0:	00a7d493          	srli	s1,a5,0xa
    800012a4:	04b2                	slli	s1,s1,0xc
  return pa;
    800012a6:	bf9d                	j	8000121c <walkaddr+0x1a>

00000000800012a8 <kvmmap>:
{
    800012a8:	1141                	addi	sp,sp,-16
    800012aa:	e406                	sd	ra,8(sp)
    800012ac:	e022                	sd	s0,0(sp)
    800012ae:	0800                	addi	s0,sp,16
  if(mappages(kernel_pagetable, va, sz, pa, perm) != 0)
    800012b0:	8736                	mv	a4,a3
    800012b2:	86ae                	mv	a3,a1
    800012b4:	85aa                	mv	a1,a0
    800012b6:	00008797          	auipc	a5,0x8
    800012ba:	d5a78793          	addi	a5,a5,-678 # 80009010 <kernel_pagetable>
    800012be:	6388                	ld	a0,0(a5)
    800012c0:	00000097          	auipc	ra,0x0
    800012c4:	eb6080e7          	jalr	-330(ra) # 80001176 <mappages>
    800012c8:	e509                	bnez	a0,800012d2 <kvmmap+0x2a>
}
    800012ca:	60a2                	ld	ra,8(sp)
    800012cc:	6402                	ld	s0,0(sp)
    800012ce:	0141                	addi	sp,sp,16
    800012d0:	8082                	ret
    panic("kvmmap");
    800012d2:	00007517          	auipc	a0,0x7
    800012d6:	e1650513          	addi	a0,a0,-490 # 800080e8 <digits+0xd0>
    800012da:	fffff097          	auipc	ra,0xfffff
    800012de:	29a080e7          	jalr	666(ra) # 80000574 <panic>

00000000800012e2 <kvminit>:
{
    800012e2:	1101                	addi	sp,sp,-32
    800012e4:	ec06                	sd	ra,24(sp)
    800012e6:	e822                	sd	s0,16(sp)
    800012e8:	e426                	sd	s1,8(sp)
    800012ea:	1000                	addi	s0,sp,32
  kernel_pagetable = (pagetable_t) kalloc();
    800012ec:	00000097          	auipc	ra,0x0
    800012f0:	886080e7          	jalr	-1914(ra) # 80000b72 <kalloc>
    800012f4:	00008797          	auipc	a5,0x8
    800012f8:	d0a7be23          	sd	a0,-740(a5) # 80009010 <kernel_pagetable>
  memset(kernel_pagetable, 0, PGSIZE);
    800012fc:	6605                	lui	a2,0x1
    800012fe:	4581                	li	a1,0
    80001300:	00000097          	auipc	ra,0x0
    80001304:	a5e080e7          	jalr	-1442(ra) # 80000d5e <memset>
  kvmmap(UART0, UART0, PGSIZE, PTE_R | PTE_W);
    80001308:	4699                	li	a3,6
    8000130a:	6605                	lui	a2,0x1
    8000130c:	100005b7          	lui	a1,0x10000
    80001310:	10000537          	lui	a0,0x10000
    80001314:	00000097          	auipc	ra,0x0
    80001318:	f94080e7          	jalr	-108(ra) # 800012a8 <kvmmap>
  kvmmap(VIRTIO0, VIRTIO0, PGSIZE, PTE_R | PTE_W);
    8000131c:	4699                	li	a3,6
    8000131e:	6605                	lui	a2,0x1
    80001320:	100015b7          	lui	a1,0x10001
    80001324:	10001537          	lui	a0,0x10001
    80001328:	00000097          	auipc	ra,0x0
    8000132c:	f80080e7          	jalr	-128(ra) # 800012a8 <kvmmap>
  kvmmap(CLINT, CLINT, 0x10000, PTE_R | PTE_W);
    80001330:	4699                	li	a3,6
    80001332:	6641                	lui	a2,0x10
    80001334:	020005b7          	lui	a1,0x2000
    80001338:	02000537          	lui	a0,0x2000
    8000133c:	00000097          	auipc	ra,0x0
    80001340:	f6c080e7          	jalr	-148(ra) # 800012a8 <kvmmap>
  kvmmap(PLIC, PLIC, 0x400000, PTE_R | PTE_W);
    80001344:	4699                	li	a3,6
    80001346:	00400637          	lui	a2,0x400
    8000134a:	0c0005b7          	lui	a1,0xc000
    8000134e:	0c000537          	lui	a0,0xc000
    80001352:	00000097          	auipc	ra,0x0
    80001356:	f56080e7          	jalr	-170(ra) # 800012a8 <kvmmap>
  kvmmap(KERNBASE, KERNBASE, (uint64)etext-KERNBASE, PTE_R | PTE_X);
    8000135a:	00007497          	auipc	s1,0x7
    8000135e:	ca648493          	addi	s1,s1,-858 # 80008000 <etext>
    80001362:	46a9                	li	a3,10
    80001364:	80007617          	auipc	a2,0x80007
    80001368:	c9c60613          	addi	a2,a2,-868 # 8000 <_entry-0x7fff8000>
    8000136c:	4585                	li	a1,1
    8000136e:	05fe                	slli	a1,a1,0x1f
    80001370:	852e                	mv	a0,a1
    80001372:	00000097          	auipc	ra,0x0
    80001376:	f36080e7          	jalr	-202(ra) # 800012a8 <kvmmap>
  kvmmap((uint64)etext, (uint64)etext, PHYSTOP-(uint64)etext, PTE_R | PTE_W);
    8000137a:	4699                	li	a3,6
    8000137c:	4645                	li	a2,17
    8000137e:	066e                	slli	a2,a2,0x1b
    80001380:	8e05                	sub	a2,a2,s1
    80001382:	85a6                	mv	a1,s1
    80001384:	8526                	mv	a0,s1
    80001386:	00000097          	auipc	ra,0x0
    8000138a:	f22080e7          	jalr	-222(ra) # 800012a8 <kvmmap>
  kvmmap(TRAMPOLINE, (uint64)trampoline, PGSIZE, PTE_R | PTE_X);
    8000138e:	46a9                	li	a3,10
    80001390:	6605                	lui	a2,0x1
    80001392:	00006597          	auipc	a1,0x6
    80001396:	c6e58593          	addi	a1,a1,-914 # 80007000 <_trampoline>
    8000139a:	04000537          	lui	a0,0x4000
    8000139e:	157d                	addi	a0,a0,-1
    800013a0:	0532                	slli	a0,a0,0xc
    800013a2:	00000097          	auipc	ra,0x0
    800013a6:	f06080e7          	jalr	-250(ra) # 800012a8 <kvmmap>
}
    800013aa:	60e2                	ld	ra,24(sp)
    800013ac:	6442                	ld	s0,16(sp)
    800013ae:	64a2                	ld	s1,8(sp)
    800013b0:	6105                	addi	sp,sp,32
    800013b2:	8082                	ret

00000000800013b4 <uvmunmap>:
// Remove npages of mappings starting from va. va must be
// page-aligned. The mappings must exist.
// Optionally free the physical memory.
void
uvmunmap(pagetable_t pagetable, uint64 va, uint64 npages, int do_free)
{
    800013b4:	715d                	addi	sp,sp,-80
    800013b6:	e486                	sd	ra,72(sp)
    800013b8:	e0a2                	sd	s0,64(sp)
    800013ba:	fc26                	sd	s1,56(sp)
    800013bc:	f84a                	sd	s2,48(sp)
    800013be:	f44e                	sd	s3,40(sp)
    800013c0:	f052                	sd	s4,32(sp)
    800013c2:	ec56                	sd	s5,24(sp)
    800013c4:	e85a                	sd	s6,16(sp)
    800013c6:	e45e                	sd	s7,8(sp)
    800013c8:	0880                	addi	s0,sp,80
  uint64 a;
  pte_t *pte;

  if((va % PGSIZE) != 0)
    800013ca:	6785                	lui	a5,0x1
    800013cc:	17fd                	addi	a5,a5,-1
    800013ce:	8fed                	and	a5,a5,a1
    800013d0:	e795                	bnez	a5,800013fc <uvmunmap+0x48>
    800013d2:	8a2a                	mv	s4,a0
    800013d4:	84ae                	mv	s1,a1
    800013d6:	8ab6                	mv	s5,a3
    panic("uvmunmap: not aligned");
  for(a = va; a < va + npages*PGSIZE; a += PGSIZE){
    800013d8:	0632                	slli	a2,a2,0xc
    800013da:	00b609b3          	add	s3,a2,a1
      continue;
      //panic("uvmunmap: walk");
    if((*pte & PTE_V) == 0)
      continue;
      //panic("uvmunmap: not mapped");
    if(PTE_FLAGS(*pte) == PTE_V)
    800013de:	4b85                	li	s7,1
  for(a = va; a < va + npages*PGSIZE; a += PGSIZE){
    800013e0:	6b05                	lui	s6,0x1
    800013e2:	0535e863          	bltu	a1,s3,80001432 <uvmunmap+0x7e>
      uint64 pa = PTE2PA(*pte);
      kfree((void*)pa);
    }
    *pte = 0;
  }
}
    800013e6:	60a6                	ld	ra,72(sp)
    800013e8:	6406                	ld	s0,64(sp)
    800013ea:	74e2                	ld	s1,56(sp)
    800013ec:	7942                	ld	s2,48(sp)
    800013ee:	79a2                	ld	s3,40(sp)
    800013f0:	7a02                	ld	s4,32(sp)
    800013f2:	6ae2                	ld	s5,24(sp)
    800013f4:	6b42                	ld	s6,16(sp)
    800013f6:	6ba2                	ld	s7,8(sp)
    800013f8:	6161                	addi	sp,sp,80
    800013fa:	8082                	ret
    panic("uvmunmap: not aligned");
    800013fc:	00007517          	auipc	a0,0x7
    80001400:	cf450513          	addi	a0,a0,-780 # 800080f0 <digits+0xd8>
    80001404:	fffff097          	auipc	ra,0xfffff
    80001408:	170080e7          	jalr	368(ra) # 80000574 <panic>
      panic("uvmunmap: not a leaf");
    8000140c:	00007517          	auipc	a0,0x7
    80001410:	cfc50513          	addi	a0,a0,-772 # 80008108 <digits+0xf0>
    80001414:	fffff097          	auipc	ra,0xfffff
    80001418:	160080e7          	jalr	352(ra) # 80000574 <panic>
      uint64 pa = PTE2PA(*pte);
    8000141c:	8129                	srli	a0,a0,0xa
      kfree((void*)pa);
    8000141e:	0532                	slli	a0,a0,0xc
    80001420:	fffff097          	auipc	ra,0xfffff
    80001424:	652080e7          	jalr	1618(ra) # 80000a72 <kfree>
    *pte = 0;
    80001428:	00093023          	sd	zero,0(s2)
  for(a = va; a < va + npages*PGSIZE; a += PGSIZE){
    8000142c:	94da                	add	s1,s1,s6
    8000142e:	fb34fce3          	bleu	s3,s1,800013e6 <uvmunmap+0x32>
    if((pte = walk(pagetable, a, 0)) == 0)
    80001432:	4601                	li	a2,0
    80001434:	85a6                	mv	a1,s1
    80001436:	8552                	mv	a0,s4
    80001438:	00000097          	auipc	ra,0x0
    8000143c:	c36080e7          	jalr	-970(ra) # 8000106e <walk>
    80001440:	892a                	mv	s2,a0
    80001442:	d56d                	beqz	a0,8000142c <uvmunmap+0x78>
    if((*pte & PTE_V) == 0)
    80001444:	6108                	ld	a0,0(a0)
    80001446:	00157793          	andi	a5,a0,1
    8000144a:	d3ed                	beqz	a5,8000142c <uvmunmap+0x78>
    if(PTE_FLAGS(*pte) == PTE_V)
    8000144c:	3ff57793          	andi	a5,a0,1023
    80001450:	fb778ee3          	beq	a5,s7,8000140c <uvmunmap+0x58>
    if(do_free){
    80001454:	fc0a8ae3          	beqz	s5,80001428 <uvmunmap+0x74>
    80001458:	b7d1                	j	8000141c <uvmunmap+0x68>

000000008000145a <uvmcreate>:

// create an empty user page table.
// returns 0 if out of memory.
pagetable_t
uvmcreate()
{
    8000145a:	1101                	addi	sp,sp,-32
    8000145c:	ec06                	sd	ra,24(sp)
    8000145e:	e822                	sd	s0,16(sp)
    80001460:	e426                	sd	s1,8(sp)
    80001462:	1000                	addi	s0,sp,32
  pagetable_t pagetable;
  pagetable = (pagetable_t) kalloc();
    80001464:	fffff097          	auipc	ra,0xfffff
    80001468:	70e080e7          	jalr	1806(ra) # 80000b72 <kalloc>
    8000146c:	84aa                	mv	s1,a0
  if(pagetable == 0)
    8000146e:	c519                	beqz	a0,8000147c <uvmcreate+0x22>
    return 0;
  memset(pagetable, 0, PGSIZE);
    80001470:	6605                	lui	a2,0x1
    80001472:	4581                	li	a1,0
    80001474:	00000097          	auipc	ra,0x0
    80001478:	8ea080e7          	jalr	-1814(ra) # 80000d5e <memset>
  return pagetable;
}
    8000147c:	8526                	mv	a0,s1
    8000147e:	60e2                	ld	ra,24(sp)
    80001480:	6442                	ld	s0,16(sp)
    80001482:	64a2                	ld	s1,8(sp)
    80001484:	6105                	addi	sp,sp,32
    80001486:	8082                	ret

0000000080001488 <uvminit>:
// Load the user initcode into address 0 of pagetable,
// for the very first process.
// sz must be less than a page.
void
uvminit(pagetable_t pagetable, uchar *src, uint sz)
{
    80001488:	7179                	addi	sp,sp,-48
    8000148a:	f406                	sd	ra,40(sp)
    8000148c:	f022                	sd	s0,32(sp)
    8000148e:	ec26                	sd	s1,24(sp)
    80001490:	e84a                	sd	s2,16(sp)
    80001492:	e44e                	sd	s3,8(sp)
    80001494:	e052                	sd	s4,0(sp)
    80001496:	1800                	addi	s0,sp,48
  char *mem;

  if(sz >= PGSIZE)
    80001498:	6785                	lui	a5,0x1
    8000149a:	04f67863          	bleu	a5,a2,800014ea <uvminit+0x62>
    8000149e:	8a2a                	mv	s4,a0
    800014a0:	89ae                	mv	s3,a1
    800014a2:	84b2                	mv	s1,a2
    panic("inituvm: more than a page");
  mem = kalloc();
    800014a4:	fffff097          	auipc	ra,0xfffff
    800014a8:	6ce080e7          	jalr	1742(ra) # 80000b72 <kalloc>
    800014ac:	892a                	mv	s2,a0
  memset(mem, 0, PGSIZE);
    800014ae:	6605                	lui	a2,0x1
    800014b0:	4581                	li	a1,0
    800014b2:	00000097          	auipc	ra,0x0
    800014b6:	8ac080e7          	jalr	-1876(ra) # 80000d5e <memset>
  mappages(pagetable, 0, PGSIZE, (uint64)mem, PTE_W|PTE_R|PTE_X|PTE_U);
    800014ba:	4779                	li	a4,30
    800014bc:	86ca                	mv	a3,s2
    800014be:	6605                	lui	a2,0x1
    800014c0:	4581                	li	a1,0
    800014c2:	8552                	mv	a0,s4
    800014c4:	00000097          	auipc	ra,0x0
    800014c8:	cb2080e7          	jalr	-846(ra) # 80001176 <mappages>
  memmove(mem, src, sz);
    800014cc:	8626                	mv	a2,s1
    800014ce:	85ce                	mv	a1,s3
    800014d0:	854a                	mv	a0,s2
    800014d2:	00000097          	auipc	ra,0x0
    800014d6:	8f8080e7          	jalr	-1800(ra) # 80000dca <memmove>
}
    800014da:	70a2                	ld	ra,40(sp)
    800014dc:	7402                	ld	s0,32(sp)
    800014de:	64e2                	ld	s1,24(sp)
    800014e0:	6942                	ld	s2,16(sp)
    800014e2:	69a2                	ld	s3,8(sp)
    800014e4:	6a02                	ld	s4,0(sp)
    800014e6:	6145                	addi	sp,sp,48
    800014e8:	8082                	ret
    panic("inituvm: more than a page");
    800014ea:	00007517          	auipc	a0,0x7
    800014ee:	c3650513          	addi	a0,a0,-970 # 80008120 <digits+0x108>
    800014f2:	fffff097          	auipc	ra,0xfffff
    800014f6:	082080e7          	jalr	130(ra) # 80000574 <panic>

00000000800014fa <uvmdealloc>:
// newsz.  oldsz and newsz need not be page-aligned, nor does newsz
// need to be less than oldsz.  oldsz can be larger than the actual
// process size.  Returns the new process size.
uint64
uvmdealloc(pagetable_t pagetable, uint64 oldsz, uint64 newsz)
{
    800014fa:	1101                	addi	sp,sp,-32
    800014fc:	ec06                	sd	ra,24(sp)
    800014fe:	e822                	sd	s0,16(sp)
    80001500:	e426                	sd	s1,8(sp)
    80001502:	1000                	addi	s0,sp,32
  if(newsz >= oldsz)
    return oldsz;
    80001504:	84ae                	mv	s1,a1
  if(newsz >= oldsz)
    80001506:	00b67d63          	bleu	a1,a2,80001520 <uvmdealloc+0x26>
    8000150a:	84b2                	mv	s1,a2

  if(PGROUNDUP(newsz) < PGROUNDUP(oldsz)){
    8000150c:	6605                	lui	a2,0x1
    8000150e:	167d                	addi	a2,a2,-1
    80001510:	00c487b3          	add	a5,s1,a2
    80001514:	777d                	lui	a4,0xfffff
    80001516:	8ff9                	and	a5,a5,a4
    80001518:	962e                	add	a2,a2,a1
    8000151a:	8e79                	and	a2,a2,a4
    8000151c:	00c7e863          	bltu	a5,a2,8000152c <uvmdealloc+0x32>
    int npages = (PGROUNDUP(oldsz) - PGROUNDUP(newsz)) / PGSIZE;
    uvmunmap(pagetable, PGROUNDUP(newsz), npages, 1);
  }

  return newsz;
}
    80001520:	8526                	mv	a0,s1
    80001522:	60e2                	ld	ra,24(sp)
    80001524:	6442                	ld	s0,16(sp)
    80001526:	64a2                	ld	s1,8(sp)
    80001528:	6105                	addi	sp,sp,32
    8000152a:	8082                	ret
    int npages = (PGROUNDUP(oldsz) - PGROUNDUP(newsz)) / PGSIZE;
    8000152c:	8e1d                	sub	a2,a2,a5
    8000152e:	8231                	srli	a2,a2,0xc
    uvmunmap(pagetable, PGROUNDUP(newsz), npages, 1);
    80001530:	4685                	li	a3,1
    80001532:	2601                	sext.w	a2,a2
    80001534:	85be                	mv	a1,a5
    80001536:	00000097          	auipc	ra,0x0
    8000153a:	e7e080e7          	jalr	-386(ra) # 800013b4 <uvmunmap>
    8000153e:	b7cd                	j	80001520 <uvmdealloc+0x26>

0000000080001540 <uvmalloc>:
  if(newsz < oldsz)
    80001540:	0ab66163          	bltu	a2,a1,800015e2 <uvmalloc+0xa2>
{
    80001544:	7139                	addi	sp,sp,-64
    80001546:	fc06                	sd	ra,56(sp)
    80001548:	f822                	sd	s0,48(sp)
    8000154a:	f426                	sd	s1,40(sp)
    8000154c:	f04a                	sd	s2,32(sp)
    8000154e:	ec4e                	sd	s3,24(sp)
    80001550:	e852                	sd	s4,16(sp)
    80001552:	e456                	sd	s5,8(sp)
    80001554:	0080                	addi	s0,sp,64
  oldsz = PGROUNDUP(oldsz);
    80001556:	6a05                	lui	s4,0x1
    80001558:	1a7d                	addi	s4,s4,-1
    8000155a:	95d2                	add	a1,a1,s4
    8000155c:	7a7d                	lui	s4,0xfffff
    8000155e:	0145fa33          	and	s4,a1,s4
  for(a = oldsz; a < newsz; a += PGSIZE){
    80001562:	08ca7263          	bleu	a2,s4,800015e6 <uvmalloc+0xa6>
    80001566:	89b2                	mv	s3,a2
    80001568:	8aaa                	mv	s5,a0
    8000156a:	8952                	mv	s2,s4
    mem = kalloc();
    8000156c:	fffff097          	auipc	ra,0xfffff
    80001570:	606080e7          	jalr	1542(ra) # 80000b72 <kalloc>
    80001574:	84aa                	mv	s1,a0
    if(mem == 0){
    80001576:	c51d                	beqz	a0,800015a4 <uvmalloc+0x64>
    memset(mem, 0, PGSIZE);
    80001578:	6605                	lui	a2,0x1
    8000157a:	4581                	li	a1,0
    8000157c:	fffff097          	auipc	ra,0xfffff
    80001580:	7e2080e7          	jalr	2018(ra) # 80000d5e <memset>
    if(mappages(pagetable, a, PGSIZE, (uint64)mem, PTE_W|PTE_X|PTE_R|PTE_U) != 0){
    80001584:	4779                	li	a4,30
    80001586:	86a6                	mv	a3,s1
    80001588:	6605                	lui	a2,0x1
    8000158a:	85ca                	mv	a1,s2
    8000158c:	8556                	mv	a0,s5
    8000158e:	00000097          	auipc	ra,0x0
    80001592:	be8080e7          	jalr	-1048(ra) # 80001176 <mappages>
    80001596:	e905                	bnez	a0,800015c6 <uvmalloc+0x86>
  for(a = oldsz; a < newsz; a += PGSIZE){
    80001598:	6785                	lui	a5,0x1
    8000159a:	993e                	add	s2,s2,a5
    8000159c:	fd3968e3          	bltu	s2,s3,8000156c <uvmalloc+0x2c>
  return newsz;
    800015a0:	854e                	mv	a0,s3
    800015a2:	a809                	j	800015b4 <uvmalloc+0x74>
      uvmdealloc(pagetable, a, oldsz);
    800015a4:	8652                	mv	a2,s4
    800015a6:	85ca                	mv	a1,s2
    800015a8:	8556                	mv	a0,s5
    800015aa:	00000097          	auipc	ra,0x0
    800015ae:	f50080e7          	jalr	-176(ra) # 800014fa <uvmdealloc>
      return 0;
    800015b2:	4501                	li	a0,0
}
    800015b4:	70e2                	ld	ra,56(sp)
    800015b6:	7442                	ld	s0,48(sp)
    800015b8:	74a2                	ld	s1,40(sp)
    800015ba:	7902                	ld	s2,32(sp)
    800015bc:	69e2                	ld	s3,24(sp)
    800015be:	6a42                	ld	s4,16(sp)
    800015c0:	6aa2                	ld	s5,8(sp)
    800015c2:	6121                	addi	sp,sp,64
    800015c4:	8082                	ret
      kfree(mem);
    800015c6:	8526                	mv	a0,s1
    800015c8:	fffff097          	auipc	ra,0xfffff
    800015cc:	4aa080e7          	jalr	1194(ra) # 80000a72 <kfree>
      uvmdealloc(pagetable, a, oldsz);
    800015d0:	8652                	mv	a2,s4
    800015d2:	85ca                	mv	a1,s2
    800015d4:	8556                	mv	a0,s5
    800015d6:	00000097          	auipc	ra,0x0
    800015da:	f24080e7          	jalr	-220(ra) # 800014fa <uvmdealloc>
      return 0;
    800015de:	4501                	li	a0,0
    800015e0:	bfd1                	j	800015b4 <uvmalloc+0x74>
    return oldsz;
    800015e2:	852e                	mv	a0,a1
}
    800015e4:	8082                	ret
  return newsz;
    800015e6:	8532                	mv	a0,a2
    800015e8:	b7f1                	j	800015b4 <uvmalloc+0x74>

00000000800015ea <freewalk>:

// Recursively free page-table pages.
// All leaf mappings must already have been removed.
void
freewalk(pagetable_t pagetable)
{
    800015ea:	7179                	addi	sp,sp,-48
    800015ec:	f406                	sd	ra,40(sp)
    800015ee:	f022                	sd	s0,32(sp)
    800015f0:	ec26                	sd	s1,24(sp)
    800015f2:	e84a                	sd	s2,16(sp)
    800015f4:	e44e                	sd	s3,8(sp)
    800015f6:	e052                	sd	s4,0(sp)
    800015f8:	1800                	addi	s0,sp,48
    800015fa:	8a2a                	mv	s4,a0
  // there are 2^9 = 512 PTEs in a page table.
  for(int i = 0; i < 512; i++){
    800015fc:	84aa                	mv	s1,a0
    800015fe:	6905                	lui	s2,0x1
    80001600:	992a                	add	s2,s2,a0
    pte_t pte = pagetable[i];
    if((pte & PTE_V) && (pte & (PTE_R|PTE_W|PTE_X)) == 0){
    80001602:	4985                	li	s3,1
    80001604:	a821                	j	8000161c <freewalk+0x32>
      // this PTE points to a lower-level page table.
      uint64 child = PTE2PA(pte);
    80001606:	8129                	srli	a0,a0,0xa
      freewalk((pagetable_t)child);
    80001608:	0532                	slli	a0,a0,0xc
    8000160a:	00000097          	auipc	ra,0x0
    8000160e:	fe0080e7          	jalr	-32(ra) # 800015ea <freewalk>
      pagetable[i] = 0;
    80001612:	0004b023          	sd	zero,0(s1)
  for(int i = 0; i < 512; i++){
    80001616:	04a1                	addi	s1,s1,8
    80001618:	03248163          	beq	s1,s2,8000163a <freewalk+0x50>
    pte_t pte = pagetable[i];
    8000161c:	6088                	ld	a0,0(s1)
    if((pte & PTE_V) && (pte & (PTE_R|PTE_W|PTE_X)) == 0){
    8000161e:	00f57793          	andi	a5,a0,15
    80001622:	ff3782e3          	beq	a5,s3,80001606 <freewalk+0x1c>
    } else if(pte & PTE_V){
    80001626:	8905                	andi	a0,a0,1
    80001628:	d57d                	beqz	a0,80001616 <freewalk+0x2c>
      panic("freewalk: leaf");
    8000162a:	00007517          	auipc	a0,0x7
    8000162e:	b1650513          	addi	a0,a0,-1258 # 80008140 <digits+0x128>
    80001632:	fffff097          	auipc	ra,0xfffff
    80001636:	f42080e7          	jalr	-190(ra) # 80000574 <panic>
    }
  }
  kfree((void*)pagetable);
    8000163a:	8552                	mv	a0,s4
    8000163c:	fffff097          	auipc	ra,0xfffff
    80001640:	436080e7          	jalr	1078(ra) # 80000a72 <kfree>
}
    80001644:	70a2                	ld	ra,40(sp)
    80001646:	7402                	ld	s0,32(sp)
    80001648:	64e2                	ld	s1,24(sp)
    8000164a:	6942                	ld	s2,16(sp)
    8000164c:	69a2                	ld	s3,8(sp)
    8000164e:	6a02                	ld	s4,0(sp)
    80001650:	6145                	addi	sp,sp,48
    80001652:	8082                	ret

0000000080001654 <uvmfree>:

// Free user memory pages,
// then free page-table pages.
void
uvmfree(pagetable_t pagetable, uint64 sz)
{
    80001654:	1101                	addi	sp,sp,-32
    80001656:	ec06                	sd	ra,24(sp)
    80001658:	e822                	sd	s0,16(sp)
    8000165a:	e426                	sd	s1,8(sp)
    8000165c:	1000                	addi	s0,sp,32
    8000165e:	84aa                	mv	s1,a0
  if(sz > 0)
    80001660:	e999                	bnez	a1,80001676 <uvmfree+0x22>
    uvmunmap(pagetable, 0, PGROUNDUP(sz)/PGSIZE, 1);
  freewalk(pagetable);
    80001662:	8526                	mv	a0,s1
    80001664:	00000097          	auipc	ra,0x0
    80001668:	f86080e7          	jalr	-122(ra) # 800015ea <freewalk>
}
    8000166c:	60e2                	ld	ra,24(sp)
    8000166e:	6442                	ld	s0,16(sp)
    80001670:	64a2                	ld	s1,8(sp)
    80001672:	6105                	addi	sp,sp,32
    80001674:	8082                	ret
    uvmunmap(pagetable, 0, PGROUNDUP(sz)/PGSIZE, 1);
    80001676:	6605                	lui	a2,0x1
    80001678:	167d                	addi	a2,a2,-1
    8000167a:	962e                	add	a2,a2,a1
    8000167c:	4685                	li	a3,1
    8000167e:	8231                	srli	a2,a2,0xc
    80001680:	4581                	li	a1,0
    80001682:	00000097          	auipc	ra,0x0
    80001686:	d32080e7          	jalr	-718(ra) # 800013b4 <uvmunmap>
    8000168a:	bfe1                	j	80001662 <uvmfree+0xe>

000000008000168c <uvmcopy>:
  pte_t *pte;
  uint64 pa, i;
  uint flags;
  char *mem;

  for(i = 0; i < sz; i += PGSIZE){
    8000168c:	ca4d                	beqz	a2,8000173e <uvmcopy+0xb2>
{
    8000168e:	715d                	addi	sp,sp,-80
    80001690:	e486                	sd	ra,72(sp)
    80001692:	e0a2                	sd	s0,64(sp)
    80001694:	fc26                	sd	s1,56(sp)
    80001696:	f84a                	sd	s2,48(sp)
    80001698:	f44e                	sd	s3,40(sp)
    8000169a:	f052                	sd	s4,32(sp)
    8000169c:	ec56                	sd	s5,24(sp)
    8000169e:	e85a                	sd	s6,16(sp)
    800016a0:	e45e                	sd	s7,8(sp)
    800016a2:	0880                	addi	s0,sp,80
    800016a4:	8a32                	mv	s4,a2
    800016a6:	8b2e                	mv	s6,a1
    800016a8:	8aaa                	mv	s5,a0
  for(i = 0; i < sz; i += PGSIZE){
    800016aa:	4481                	li	s1,0
    800016ac:	a029                	j	800016b6 <uvmcopy+0x2a>
    800016ae:	6785                	lui	a5,0x1
    800016b0:	94be                	add	s1,s1,a5
    800016b2:	0744fa63          	bleu	s4,s1,80001726 <uvmcopy+0x9a>
    if((pte = walk(old, i, 0)) == 0)
    800016b6:	4601                	li	a2,0
    800016b8:	85a6                	mv	a1,s1
    800016ba:	8556                	mv	a0,s5
    800016bc:	00000097          	auipc	ra,0x0
    800016c0:	9b2080e7          	jalr	-1614(ra) # 8000106e <walk>
    800016c4:	d56d                	beqz	a0,800016ae <uvmcopy+0x22>
      continue;
      //panic("uvmcopy: pte should exist");
    if((*pte & PTE_V) == 0)
    800016c6:	6118                	ld	a4,0(a0)
    800016c8:	00177793          	andi	a5,a4,1
    800016cc:	d3ed                	beqz	a5,800016ae <uvmcopy+0x22>
      continue;
      //panic("uvmcopy: page not present");
    pa = PTE2PA(*pte);
    800016ce:	00a75793          	srli	a5,a4,0xa
    800016d2:	00c79b93          	slli	s7,a5,0xc
    flags = PTE_FLAGS(*pte);
    800016d6:	3ff77913          	andi	s2,a4,1023
    if((mem = kalloc()) == 0)
    800016da:	fffff097          	auipc	ra,0xfffff
    800016de:	498080e7          	jalr	1176(ra) # 80000b72 <kalloc>
    800016e2:	89aa                	mv	s3,a0
    800016e4:	c515                	beqz	a0,80001710 <uvmcopy+0x84>
      goto err;
    memmove(mem, (char*)pa, PGSIZE);
    800016e6:	6605                	lui	a2,0x1
    800016e8:	85de                	mv	a1,s7
    800016ea:	fffff097          	auipc	ra,0xfffff
    800016ee:	6e0080e7          	jalr	1760(ra) # 80000dca <memmove>
    if(mappages(new, i, PGSIZE, (uint64)mem, flags) != 0){
    800016f2:	874a                	mv	a4,s2
    800016f4:	86ce                	mv	a3,s3
    800016f6:	6605                	lui	a2,0x1
    800016f8:	85a6                	mv	a1,s1
    800016fa:	855a                	mv	a0,s6
    800016fc:	00000097          	auipc	ra,0x0
    80001700:	a7a080e7          	jalr	-1414(ra) # 80001176 <mappages>
    80001704:	d54d                	beqz	a0,800016ae <uvmcopy+0x22>
      kfree(mem);
    80001706:	854e                	mv	a0,s3
    80001708:	fffff097          	auipc	ra,0xfffff
    8000170c:	36a080e7          	jalr	874(ra) # 80000a72 <kfree>
    }
  }
  return 0;

 err:
  uvmunmap(new, 0, i / PGSIZE, 1);
    80001710:	4685                	li	a3,1
    80001712:	00c4d613          	srli	a2,s1,0xc
    80001716:	4581                	li	a1,0
    80001718:	855a                	mv	a0,s6
    8000171a:	00000097          	auipc	ra,0x0
    8000171e:	c9a080e7          	jalr	-870(ra) # 800013b4 <uvmunmap>
  return -1;
    80001722:	557d                	li	a0,-1
    80001724:	a011                	j	80001728 <uvmcopy+0x9c>
  return 0;
    80001726:	4501                	li	a0,0
}
    80001728:	60a6                	ld	ra,72(sp)
    8000172a:	6406                	ld	s0,64(sp)
    8000172c:	74e2                	ld	s1,56(sp)
    8000172e:	7942                	ld	s2,48(sp)
    80001730:	79a2                	ld	s3,40(sp)
    80001732:	7a02                	ld	s4,32(sp)
    80001734:	6ae2                	ld	s5,24(sp)
    80001736:	6b42                	ld	s6,16(sp)
    80001738:	6ba2                	ld	s7,8(sp)
    8000173a:	6161                	addi	sp,sp,80
    8000173c:	8082                	ret
  return 0;
    8000173e:	4501                	li	a0,0
}
    80001740:	8082                	ret

0000000080001742 <uvmclear>:

// mark a PTE invalid for user access.
// used by exec for the user stack guard page.
void
uvmclear(pagetable_t pagetable, uint64 va)
{
    80001742:	1141                	addi	sp,sp,-16
    80001744:	e406                	sd	ra,8(sp)
    80001746:	e022                	sd	s0,0(sp)
    80001748:	0800                	addi	s0,sp,16
  pte_t *pte;
  
  pte = walk(pagetable, va, 0);
    8000174a:	4601                	li	a2,0
    8000174c:	00000097          	auipc	ra,0x0
    80001750:	922080e7          	jalr	-1758(ra) # 8000106e <walk>
  if(pte == 0)
    80001754:	c901                	beqz	a0,80001764 <uvmclear+0x22>
    panic("uvmclear");
  *pte &= ~PTE_U;
    80001756:	611c                	ld	a5,0(a0)
    80001758:	9bbd                	andi	a5,a5,-17
    8000175a:	e11c                	sd	a5,0(a0)
}
    8000175c:	60a2                	ld	ra,8(sp)
    8000175e:	6402                	ld	s0,0(sp)
    80001760:	0141                	addi	sp,sp,16
    80001762:	8082                	ret
    panic("uvmclear");
    80001764:	00007517          	auipc	a0,0x7
    80001768:	9ec50513          	addi	a0,a0,-1556 # 80008150 <digits+0x138>
    8000176c:	fffff097          	auipc	ra,0xfffff
    80001770:	e08080e7          	jalr	-504(ra) # 80000574 <panic>

0000000080001774 <copyout>:
int
copyout(pagetable_t pagetable, uint64 dstva, char *src, uint64 len)
{
  uint64 n, va0, pa0;

  while(len > 0){
    80001774:	c6bd                	beqz	a3,800017e2 <copyout+0x6e>
{
    80001776:	715d                	addi	sp,sp,-80
    80001778:	e486                	sd	ra,72(sp)
    8000177a:	e0a2                	sd	s0,64(sp)
    8000177c:	fc26                	sd	s1,56(sp)
    8000177e:	f84a                	sd	s2,48(sp)
    80001780:	f44e                	sd	s3,40(sp)
    80001782:	f052                	sd	s4,32(sp)
    80001784:	ec56                	sd	s5,24(sp)
    80001786:	e85a                	sd	s6,16(sp)
    80001788:	e45e                	sd	s7,8(sp)
    8000178a:	e062                	sd	s8,0(sp)
    8000178c:	0880                	addi	s0,sp,80
    8000178e:	8baa                	mv	s7,a0
    80001790:	8a2e                	mv	s4,a1
    80001792:	8ab2                	mv	s5,a2
    80001794:	89b6                	mv	s3,a3
    va0 = PGROUNDDOWN(dstva);
    80001796:	7c7d                	lui	s8,0xfffff
    pa0 = walkaddr(pagetable, va0);
    if(pa0 == 0)
      return -1;
    n = PGSIZE - (dstva - va0);
    80001798:	6b05                	lui	s6,0x1
    8000179a:	a015                	j	800017be <copyout+0x4a>
    if(n > len)
      n = len;
    memmove((void *)(pa0 + (dstva - va0)), src, n);
    8000179c:	9552                	add	a0,a0,s4
    8000179e:	0004861b          	sext.w	a2,s1
    800017a2:	85d6                	mv	a1,s5
    800017a4:	41250533          	sub	a0,a0,s2
    800017a8:	fffff097          	auipc	ra,0xfffff
    800017ac:	622080e7          	jalr	1570(ra) # 80000dca <memmove>

    len -= n;
    800017b0:	409989b3          	sub	s3,s3,s1
    src += n;
    800017b4:	9aa6                	add	s5,s5,s1
    dstva = va0 + PGSIZE;
    800017b6:	01690a33          	add	s4,s2,s6
  while(len > 0){
    800017ba:	02098263          	beqz	s3,800017de <copyout+0x6a>
    va0 = PGROUNDDOWN(dstva);
    800017be:	018a7933          	and	s2,s4,s8
    pa0 = walkaddr(pagetable, va0);
    800017c2:	85ca                	mv	a1,s2
    800017c4:	855e                	mv	a0,s7
    800017c6:	00000097          	auipc	ra,0x0
    800017ca:	a3c080e7          	jalr	-1476(ra) # 80001202 <walkaddr>
    if(pa0 == 0)
    800017ce:	cd01                	beqz	a0,800017e6 <copyout+0x72>
    n = PGSIZE - (dstva - va0);
    800017d0:	414904b3          	sub	s1,s2,s4
    800017d4:	94da                	add	s1,s1,s6
    if(n > len)
    800017d6:	fc99f3e3          	bleu	s1,s3,8000179c <copyout+0x28>
    800017da:	84ce                	mv	s1,s3
    800017dc:	b7c1                	j	8000179c <copyout+0x28>
  }
  return 0;
    800017de:	4501                	li	a0,0
    800017e0:	a021                	j	800017e8 <copyout+0x74>
    800017e2:	4501                	li	a0,0
}
    800017e4:	8082                	ret
      return -1;
    800017e6:	557d                	li	a0,-1
}
    800017e8:	60a6                	ld	ra,72(sp)
    800017ea:	6406                	ld	s0,64(sp)
    800017ec:	74e2                	ld	s1,56(sp)
    800017ee:	7942                	ld	s2,48(sp)
    800017f0:	79a2                	ld	s3,40(sp)
    800017f2:	7a02                	ld	s4,32(sp)
    800017f4:	6ae2                	ld	s5,24(sp)
    800017f6:	6b42                	ld	s6,16(sp)
    800017f8:	6ba2                	ld	s7,8(sp)
    800017fa:	6c02                	ld	s8,0(sp)
    800017fc:	6161                	addi	sp,sp,80
    800017fe:	8082                	ret

0000000080001800 <copyin>:
int
copyin(pagetable_t pagetable, char *dst, uint64 srcva, uint64 len)
{
  uint64 n, va0, pa0;

  while(len > 0){
    80001800:	caa5                	beqz	a3,80001870 <copyin+0x70>
{
    80001802:	715d                	addi	sp,sp,-80
    80001804:	e486                	sd	ra,72(sp)
    80001806:	e0a2                	sd	s0,64(sp)
    80001808:	fc26                	sd	s1,56(sp)
    8000180a:	f84a                	sd	s2,48(sp)
    8000180c:	f44e                	sd	s3,40(sp)
    8000180e:	f052                	sd	s4,32(sp)
    80001810:	ec56                	sd	s5,24(sp)
    80001812:	e85a                	sd	s6,16(sp)
    80001814:	e45e                	sd	s7,8(sp)
    80001816:	e062                	sd	s8,0(sp)
    80001818:	0880                	addi	s0,sp,80
    8000181a:	8baa                	mv	s7,a0
    8000181c:	8aae                	mv	s5,a1
    8000181e:	8a32                	mv	s4,a2
    80001820:	89b6                	mv	s3,a3
    va0 = PGROUNDDOWN(srcva);
    80001822:	7c7d                	lui	s8,0xfffff
    pa0 = walkaddr(pagetable, va0);
    if(pa0 == 0)
      return -1;
    n = PGSIZE - (srcva - va0);
    80001824:	6b05                	lui	s6,0x1
    80001826:	a01d                	j	8000184c <copyin+0x4c>
    if(n > len)
      n = len;
    memmove(dst, (void *)(pa0 + (srcva - va0)), n);
    80001828:	014505b3          	add	a1,a0,s4
    8000182c:	0004861b          	sext.w	a2,s1
    80001830:	412585b3          	sub	a1,a1,s2
    80001834:	8556                	mv	a0,s5
    80001836:	fffff097          	auipc	ra,0xfffff
    8000183a:	594080e7          	jalr	1428(ra) # 80000dca <memmove>

    len -= n;
    8000183e:	409989b3          	sub	s3,s3,s1
    dst += n;
    80001842:	9aa6                	add	s5,s5,s1
    srcva = va0 + PGSIZE;
    80001844:	01690a33          	add	s4,s2,s6
  while(len > 0){
    80001848:	02098263          	beqz	s3,8000186c <copyin+0x6c>
    va0 = PGROUNDDOWN(srcva);
    8000184c:	018a7933          	and	s2,s4,s8
    pa0 = walkaddr(pagetable, va0);
    80001850:	85ca                	mv	a1,s2
    80001852:	855e                	mv	a0,s7
    80001854:	00000097          	auipc	ra,0x0
    80001858:	9ae080e7          	jalr	-1618(ra) # 80001202 <walkaddr>
    if(pa0 == 0)
    8000185c:	cd01                	beqz	a0,80001874 <copyin+0x74>
    n = PGSIZE - (srcva - va0);
    8000185e:	414904b3          	sub	s1,s2,s4
    80001862:	94da                	add	s1,s1,s6
    if(n > len)
    80001864:	fc99f2e3          	bleu	s1,s3,80001828 <copyin+0x28>
    80001868:	84ce                	mv	s1,s3
    8000186a:	bf7d                	j	80001828 <copyin+0x28>
  }
  return 0;
    8000186c:	4501                	li	a0,0
    8000186e:	a021                	j	80001876 <copyin+0x76>
    80001870:	4501                	li	a0,0
}
    80001872:	8082                	ret
      return -1;
    80001874:	557d                	li	a0,-1
}
    80001876:	60a6                	ld	ra,72(sp)
    80001878:	6406                	ld	s0,64(sp)
    8000187a:	74e2                	ld	s1,56(sp)
    8000187c:	7942                	ld	s2,48(sp)
    8000187e:	79a2                	ld	s3,40(sp)
    80001880:	7a02                	ld	s4,32(sp)
    80001882:	6ae2                	ld	s5,24(sp)
    80001884:	6b42                	ld	s6,16(sp)
    80001886:	6ba2                	ld	s7,8(sp)
    80001888:	6c02                	ld	s8,0(sp)
    8000188a:	6161                	addi	sp,sp,80
    8000188c:	8082                	ret

000000008000188e <copyinstr>:
copyinstr(pagetable_t pagetable, char *dst, uint64 srcva, uint64 max)
{
  uint64 n, va0, pa0;
  int got_null = 0;

  while(got_null == 0 && max > 0){
    8000188e:	ced5                	beqz	a3,8000194a <copyinstr+0xbc>
{
    80001890:	715d                	addi	sp,sp,-80
    80001892:	e486                	sd	ra,72(sp)
    80001894:	e0a2                	sd	s0,64(sp)
    80001896:	fc26                	sd	s1,56(sp)
    80001898:	f84a                	sd	s2,48(sp)
    8000189a:	f44e                	sd	s3,40(sp)
    8000189c:	f052                	sd	s4,32(sp)
    8000189e:	ec56                	sd	s5,24(sp)
    800018a0:	e85a                	sd	s6,16(sp)
    800018a2:	e45e                	sd	s7,8(sp)
    800018a4:	e062                	sd	s8,0(sp)
    800018a6:	0880                	addi	s0,sp,80
    800018a8:	8aaa                	mv	s5,a0
    800018aa:	84ae                	mv	s1,a1
    800018ac:	8c32                	mv	s8,a2
    800018ae:	8bb6                	mv	s7,a3
    va0 = PGROUNDDOWN(srcva);
    800018b0:	7a7d                	lui	s4,0xfffff
    pa0 = walkaddr(pagetable, va0);
    if(pa0 == 0)
      return -1;
    n = PGSIZE - (srcva - va0);
    800018b2:	6985                	lui	s3,0x1
    800018b4:	4b05                	li	s6,1
    800018b6:	a801                	j	800018c6 <copyinstr+0x38>
    if(n > max)
      n = max;

    char *p = (char *) (pa0 + (srcva - va0));
    while(n > 0){
      if(*p == '\0'){
    800018b8:	87a6                	mv	a5,s1
    800018ba:	a085                	j	8000191a <copyinstr+0x8c>
        *dst = *p;
      }
      --n;
      --max;
      p++;
      dst++;
    800018bc:	84b2                	mv	s1,a2
    }

    srcva = va0 + PGSIZE;
    800018be:	01390c33          	add	s8,s2,s3
  while(got_null == 0 && max > 0){
    800018c2:	080b8063          	beqz	s7,80001942 <copyinstr+0xb4>
    va0 = PGROUNDDOWN(srcva);
    800018c6:	014c7933          	and	s2,s8,s4
    pa0 = walkaddr(pagetable, va0);
    800018ca:	85ca                	mv	a1,s2
    800018cc:	8556                	mv	a0,s5
    800018ce:	00000097          	auipc	ra,0x0
    800018d2:	934080e7          	jalr	-1740(ra) # 80001202 <walkaddr>
    if(pa0 == 0)
    800018d6:	c925                	beqz	a0,80001946 <copyinstr+0xb8>
    n = PGSIZE - (srcva - va0);
    800018d8:	41890633          	sub	a2,s2,s8
    800018dc:	964e                	add	a2,a2,s3
    if(n > max)
    800018de:	00cbf363          	bleu	a2,s7,800018e4 <copyinstr+0x56>
    800018e2:	865e                	mv	a2,s7
    char *p = (char *) (pa0 + (srcva - va0));
    800018e4:	9562                	add	a0,a0,s8
    800018e6:	41250533          	sub	a0,a0,s2
    while(n > 0){
    800018ea:	da71                	beqz	a2,800018be <copyinstr+0x30>
      if(*p == '\0'){
    800018ec:	00054703          	lbu	a4,0(a0)
    800018f0:	d761                	beqz	a4,800018b8 <copyinstr+0x2a>
    800018f2:	9626                	add	a2,a2,s1
    800018f4:	87a6                	mv	a5,s1
    800018f6:	1bfd                	addi	s7,s7,-1
    800018f8:	009b86b3          	add	a3,s7,s1
    800018fc:	409b04b3          	sub	s1,s6,s1
    80001900:	94aa                	add	s1,s1,a0
        *dst = *p;
    80001902:	00e78023          	sb	a4,0(a5) # 1000 <_entry-0x7ffff000>
      --max;
    80001906:	40f68bb3          	sub	s7,a3,a5
      p++;
    8000190a:	00f48733          	add	a4,s1,a5
      dst++;
    8000190e:	0785                	addi	a5,a5,1
    while(n > 0){
    80001910:	faf606e3          	beq	a2,a5,800018bc <copyinstr+0x2e>
      if(*p == '\0'){
    80001914:	00074703          	lbu	a4,0(a4) # fffffffffffff000 <end+0xffffffff7ffd9000>
    80001918:	f76d                	bnez	a4,80001902 <copyinstr+0x74>
        *dst = '\0';
    8000191a:	00078023          	sb	zero,0(a5)
    8000191e:	4785                	li	a5,1
  }
  if(got_null){
    80001920:	0017b513          	seqz	a0,a5
    80001924:	40a0053b          	negw	a0,a0
    80001928:	2501                	sext.w	a0,a0
    return 0;
  } else {
    return -1;
  }
}
    8000192a:	60a6                	ld	ra,72(sp)
    8000192c:	6406                	ld	s0,64(sp)
    8000192e:	74e2                	ld	s1,56(sp)
    80001930:	7942                	ld	s2,48(sp)
    80001932:	79a2                	ld	s3,40(sp)
    80001934:	7a02                	ld	s4,32(sp)
    80001936:	6ae2                	ld	s5,24(sp)
    80001938:	6b42                	ld	s6,16(sp)
    8000193a:	6ba2                	ld	s7,8(sp)
    8000193c:	6c02                	ld	s8,0(sp)
    8000193e:	6161                	addi	sp,sp,80
    80001940:	8082                	ret
    80001942:	4781                	li	a5,0
    80001944:	bff1                	j	80001920 <copyinstr+0x92>
      return -1;
    80001946:	557d                	li	a0,-1
    80001948:	b7cd                	j	8000192a <copyinstr+0x9c>
  int got_null = 0;
    8000194a:	4781                	li	a5,0
  if(got_null){
    8000194c:	0017b513          	seqz	a0,a5
    80001950:	40a0053b          	negw	a0,a0
    80001954:	2501                	sext.w	a0,a0
}
    80001956:	8082                	ret

0000000080001958 <wakeup1>:

// Wake up p if it is sleeping in wait(); used by exit().
// Caller must hold p->lock.
static void
wakeup1(struct proc *p)
{
    80001958:	1101                	addi	sp,sp,-32
    8000195a:	ec06                	sd	ra,24(sp)
    8000195c:	e822                	sd	s0,16(sp)
    8000195e:	e426                	sd	s1,8(sp)
    80001960:	1000                	addi	s0,sp,32
    80001962:	84aa                	mv	s1,a0
  if(!holding(&p->lock))
    80001964:	fffff097          	auipc	ra,0xfffff
    80001968:	284080e7          	jalr	644(ra) # 80000be8 <holding>
    8000196c:	c909                	beqz	a0,8000197e <wakeup1+0x26>
    panic("wakeup1");
  if(p->chan == p && p->state == SLEEPING) {
    8000196e:	749c                	ld	a5,40(s1)
    80001970:	00978f63          	beq	a5,s1,8000198e <wakeup1+0x36>
    p->state = RUNNABLE;
  }
}
    80001974:	60e2                	ld	ra,24(sp)
    80001976:	6442                	ld	s0,16(sp)
    80001978:	64a2                	ld	s1,8(sp)
    8000197a:	6105                	addi	sp,sp,32
    8000197c:	8082                	ret
    panic("wakeup1");
    8000197e:	00007517          	auipc	a0,0x7
    80001982:	80a50513          	addi	a0,a0,-2038 # 80008188 <states.1722+0x28>
    80001986:	fffff097          	auipc	ra,0xfffff
    8000198a:	bee080e7          	jalr	-1042(ra) # 80000574 <panic>
  if(p->chan == p && p->state == SLEEPING) {
    8000198e:	4c98                	lw	a4,24(s1)
    80001990:	4785                	li	a5,1
    80001992:	fef711e3          	bne	a4,a5,80001974 <wakeup1+0x1c>
    p->state = RUNNABLE;
    80001996:	4789                	li	a5,2
    80001998:	cc9c                	sw	a5,24(s1)
}
    8000199a:	bfe9                	j	80001974 <wakeup1+0x1c>

000000008000199c <procinit>:
{
    8000199c:	715d                	addi	sp,sp,-80
    8000199e:	e486                	sd	ra,72(sp)
    800019a0:	e0a2                	sd	s0,64(sp)
    800019a2:	fc26                	sd	s1,56(sp)
    800019a4:	f84a                	sd	s2,48(sp)
    800019a6:	f44e                	sd	s3,40(sp)
    800019a8:	f052                	sd	s4,32(sp)
    800019aa:	ec56                	sd	s5,24(sp)
    800019ac:	e85a                	sd	s6,16(sp)
    800019ae:	e45e                	sd	s7,8(sp)
    800019b0:	0880                	addi	s0,sp,80
  initlock(&pid_lock, "nextpid");
    800019b2:	00006597          	auipc	a1,0x6
    800019b6:	7de58593          	addi	a1,a1,2014 # 80008190 <states.1722+0x30>
    800019ba:	00010517          	auipc	a0,0x10
    800019be:	f9650513          	addi	a0,a0,-106 # 80011950 <pid_lock>
    800019c2:	fffff097          	auipc	ra,0xfffff
    800019c6:	210080e7          	jalr	528(ra) # 80000bd2 <initlock>
  for(p = proc; p < &proc[NPROC]; p++) {
    800019ca:	00010917          	auipc	s2,0x10
    800019ce:	39e90913          	addi	s2,s2,926 # 80011d68 <proc>
      initlock(&p->lock, "proc");
    800019d2:	00006b97          	auipc	s7,0x6
    800019d6:	7c6b8b93          	addi	s7,s7,1990 # 80008198 <states.1722+0x38>
      uint64 va = KSTACK((int) (p - proc));
    800019da:	8b4a                	mv	s6,s2
    800019dc:	00006a97          	auipc	s5,0x6
    800019e0:	624a8a93          	addi	s5,s5,1572 # 80008000 <etext>
    800019e4:	040009b7          	lui	s3,0x4000
    800019e8:	19fd                	addi	s3,s3,-1
    800019ea:	09b2                	slli	s3,s3,0xc
  for(p = proc; p < &proc[NPROC]; p++) {
    800019ec:	00016a17          	auipc	s4,0x16
    800019f0:	d7ca0a13          	addi	s4,s4,-644 # 80017768 <tickslock>
      initlock(&p->lock, "proc");
    800019f4:	85de                	mv	a1,s7
    800019f6:	854a                	mv	a0,s2
    800019f8:	fffff097          	auipc	ra,0xfffff
    800019fc:	1da080e7          	jalr	474(ra) # 80000bd2 <initlock>
      char *pa = kalloc();
    80001a00:	fffff097          	auipc	ra,0xfffff
    80001a04:	172080e7          	jalr	370(ra) # 80000b72 <kalloc>
    80001a08:	85aa                	mv	a1,a0
      if(pa == 0)
    80001a0a:	c929                	beqz	a0,80001a5c <procinit+0xc0>
      uint64 va = KSTACK((int) (p - proc));
    80001a0c:	416904b3          	sub	s1,s2,s6
    80001a10:	848d                	srai	s1,s1,0x3
    80001a12:	000ab783          	ld	a5,0(s5)
    80001a16:	02f484b3          	mul	s1,s1,a5
    80001a1a:	2485                	addiw	s1,s1,1
    80001a1c:	00d4949b          	slliw	s1,s1,0xd
    80001a20:	409984b3          	sub	s1,s3,s1
      kvmmap(va, (uint64)pa, PGSIZE, PTE_R | PTE_W);
    80001a24:	4699                	li	a3,6
    80001a26:	6605                	lui	a2,0x1
    80001a28:	8526                	mv	a0,s1
    80001a2a:	00000097          	auipc	ra,0x0
    80001a2e:	87e080e7          	jalr	-1922(ra) # 800012a8 <kvmmap>
      p->kstack = va;
    80001a32:	04993023          	sd	s1,64(s2)
  for(p = proc; p < &proc[NPROC]; p++) {
    80001a36:	16890913          	addi	s2,s2,360
    80001a3a:	fb491de3          	bne	s2,s4,800019f4 <procinit+0x58>
  kvminithart();
    80001a3e:	fffff097          	auipc	ra,0xfffff
    80001a42:	60a080e7          	jalr	1546(ra) # 80001048 <kvminithart>
}
    80001a46:	60a6                	ld	ra,72(sp)
    80001a48:	6406                	ld	s0,64(sp)
    80001a4a:	74e2                	ld	s1,56(sp)
    80001a4c:	7942                	ld	s2,48(sp)
    80001a4e:	79a2                	ld	s3,40(sp)
    80001a50:	7a02                	ld	s4,32(sp)
    80001a52:	6ae2                	ld	s5,24(sp)
    80001a54:	6b42                	ld	s6,16(sp)
    80001a56:	6ba2                	ld	s7,8(sp)
    80001a58:	6161                	addi	sp,sp,80
    80001a5a:	8082                	ret
        panic("kalloc");
    80001a5c:	00006517          	auipc	a0,0x6
    80001a60:	74450513          	addi	a0,a0,1860 # 800081a0 <states.1722+0x40>
    80001a64:	fffff097          	auipc	ra,0xfffff
    80001a68:	b10080e7          	jalr	-1264(ra) # 80000574 <panic>

0000000080001a6c <cpuid>:
{
    80001a6c:	1141                	addi	sp,sp,-16
    80001a6e:	e422                	sd	s0,8(sp)
    80001a70:	0800                	addi	s0,sp,16
  asm volatile("mv %0, tp" : "=r" (x) );
    80001a72:	8512                	mv	a0,tp
}
    80001a74:	2501                	sext.w	a0,a0
    80001a76:	6422                	ld	s0,8(sp)
    80001a78:	0141                	addi	sp,sp,16
    80001a7a:	8082                	ret

0000000080001a7c <mycpu>:
mycpu(void) {
    80001a7c:	1141                	addi	sp,sp,-16
    80001a7e:	e422                	sd	s0,8(sp)
    80001a80:	0800                	addi	s0,sp,16
    80001a82:	8792                	mv	a5,tp
  struct cpu *c = &cpus[id];
    80001a84:	2781                	sext.w	a5,a5
    80001a86:	079e                	slli	a5,a5,0x7
}
    80001a88:	00010517          	auipc	a0,0x10
    80001a8c:	ee050513          	addi	a0,a0,-288 # 80011968 <cpus>
    80001a90:	953e                	add	a0,a0,a5
    80001a92:	6422                	ld	s0,8(sp)
    80001a94:	0141                	addi	sp,sp,16
    80001a96:	8082                	ret

0000000080001a98 <myproc>:
myproc(void) {
    80001a98:	1101                	addi	sp,sp,-32
    80001a9a:	ec06                	sd	ra,24(sp)
    80001a9c:	e822                	sd	s0,16(sp)
    80001a9e:	e426                	sd	s1,8(sp)
    80001aa0:	1000                	addi	s0,sp,32
  push_off();
    80001aa2:	fffff097          	auipc	ra,0xfffff
    80001aa6:	174080e7          	jalr	372(ra) # 80000c16 <push_off>
    80001aaa:	8792                	mv	a5,tp
  struct proc *p = c->proc;
    80001aac:	2781                	sext.w	a5,a5
    80001aae:	079e                	slli	a5,a5,0x7
    80001ab0:	00010717          	auipc	a4,0x10
    80001ab4:	ea070713          	addi	a4,a4,-352 # 80011950 <pid_lock>
    80001ab8:	97ba                	add	a5,a5,a4
    80001aba:	6f84                	ld	s1,24(a5)
  pop_off();
    80001abc:	fffff097          	auipc	ra,0xfffff
    80001ac0:	1fa080e7          	jalr	506(ra) # 80000cb6 <pop_off>
}
    80001ac4:	8526                	mv	a0,s1
    80001ac6:	60e2                	ld	ra,24(sp)
    80001ac8:	6442                	ld	s0,16(sp)
    80001aca:	64a2                	ld	s1,8(sp)
    80001acc:	6105                	addi	sp,sp,32
    80001ace:	8082                	ret

0000000080001ad0 <forkret>:
{
    80001ad0:	1141                	addi	sp,sp,-16
    80001ad2:	e406                	sd	ra,8(sp)
    80001ad4:	e022                	sd	s0,0(sp)
    80001ad6:	0800                	addi	s0,sp,16
  release(&myproc()->lock);
    80001ad8:	00000097          	auipc	ra,0x0
    80001adc:	fc0080e7          	jalr	-64(ra) # 80001a98 <myproc>
    80001ae0:	fffff097          	auipc	ra,0xfffff
    80001ae4:	236080e7          	jalr	566(ra) # 80000d16 <release>
  if (first) {
    80001ae8:	00007797          	auipc	a5,0x7
    80001aec:	cc878793          	addi	a5,a5,-824 # 800087b0 <first.1682>
    80001af0:	439c                	lw	a5,0(a5)
    80001af2:	eb89                	bnez	a5,80001b04 <forkret+0x34>
  usertrapret();
    80001af4:	00001097          	auipc	ra,0x1
    80001af8:	c26080e7          	jalr	-986(ra) # 8000271a <usertrapret>
}
    80001afc:	60a2                	ld	ra,8(sp)
    80001afe:	6402                	ld	s0,0(sp)
    80001b00:	0141                	addi	sp,sp,16
    80001b02:	8082                	ret
    first = 0;
    80001b04:	00007797          	auipc	a5,0x7
    80001b08:	ca07a623          	sw	zero,-852(a5) # 800087b0 <first.1682>
    fsinit(ROOTDEV);
    80001b0c:	4505                	li	a0,1
    80001b0e:	00002097          	auipc	ra,0x2
    80001b12:	a48080e7          	jalr	-1464(ra) # 80003556 <fsinit>
    80001b16:	bff9                	j	80001af4 <forkret+0x24>

0000000080001b18 <allocpid>:
allocpid() {
    80001b18:	1101                	addi	sp,sp,-32
    80001b1a:	ec06                	sd	ra,24(sp)
    80001b1c:	e822                	sd	s0,16(sp)
    80001b1e:	e426                	sd	s1,8(sp)
    80001b20:	e04a                	sd	s2,0(sp)
    80001b22:	1000                	addi	s0,sp,32
  acquire(&pid_lock);
    80001b24:	00010917          	auipc	s2,0x10
    80001b28:	e2c90913          	addi	s2,s2,-468 # 80011950 <pid_lock>
    80001b2c:	854a                	mv	a0,s2
    80001b2e:	fffff097          	auipc	ra,0xfffff
    80001b32:	134080e7          	jalr	308(ra) # 80000c62 <acquire>
  pid = nextpid;
    80001b36:	00007797          	auipc	a5,0x7
    80001b3a:	c7e78793          	addi	a5,a5,-898 # 800087b4 <nextpid>
    80001b3e:	4384                	lw	s1,0(a5)
  nextpid = nextpid + 1;
    80001b40:	0014871b          	addiw	a4,s1,1
    80001b44:	c398                	sw	a4,0(a5)
  release(&pid_lock);
    80001b46:	854a                	mv	a0,s2
    80001b48:	fffff097          	auipc	ra,0xfffff
    80001b4c:	1ce080e7          	jalr	462(ra) # 80000d16 <release>
}
    80001b50:	8526                	mv	a0,s1
    80001b52:	60e2                	ld	ra,24(sp)
    80001b54:	6442                	ld	s0,16(sp)
    80001b56:	64a2                	ld	s1,8(sp)
    80001b58:	6902                	ld	s2,0(sp)
    80001b5a:	6105                	addi	sp,sp,32
    80001b5c:	8082                	ret

0000000080001b5e <proc_pagetable>:
{
    80001b5e:	1101                	addi	sp,sp,-32
    80001b60:	ec06                	sd	ra,24(sp)
    80001b62:	e822                	sd	s0,16(sp)
    80001b64:	e426                	sd	s1,8(sp)
    80001b66:	e04a                	sd	s2,0(sp)
    80001b68:	1000                	addi	s0,sp,32
    80001b6a:	892a                	mv	s2,a0
  pagetable = uvmcreate();
    80001b6c:	00000097          	auipc	ra,0x0
    80001b70:	8ee080e7          	jalr	-1810(ra) # 8000145a <uvmcreate>
    80001b74:	84aa                	mv	s1,a0
  if(pagetable == 0)
    80001b76:	c121                	beqz	a0,80001bb6 <proc_pagetable+0x58>
  if(mappages(pagetable, TRAMPOLINE, PGSIZE,
    80001b78:	4729                	li	a4,10
    80001b7a:	00005697          	auipc	a3,0x5
    80001b7e:	48668693          	addi	a3,a3,1158 # 80007000 <_trampoline>
    80001b82:	6605                	lui	a2,0x1
    80001b84:	040005b7          	lui	a1,0x4000
    80001b88:	15fd                	addi	a1,a1,-1
    80001b8a:	05b2                	slli	a1,a1,0xc
    80001b8c:	fffff097          	auipc	ra,0xfffff
    80001b90:	5ea080e7          	jalr	1514(ra) # 80001176 <mappages>
    80001b94:	02054863          	bltz	a0,80001bc4 <proc_pagetable+0x66>
  if(mappages(pagetable, TRAPFRAME, PGSIZE,
    80001b98:	4719                	li	a4,6
    80001b9a:	05893683          	ld	a3,88(s2)
    80001b9e:	6605                	lui	a2,0x1
    80001ba0:	020005b7          	lui	a1,0x2000
    80001ba4:	15fd                	addi	a1,a1,-1
    80001ba6:	05b6                	slli	a1,a1,0xd
    80001ba8:	8526                	mv	a0,s1
    80001baa:	fffff097          	auipc	ra,0xfffff
    80001bae:	5cc080e7          	jalr	1484(ra) # 80001176 <mappages>
    80001bb2:	02054163          	bltz	a0,80001bd4 <proc_pagetable+0x76>
}
    80001bb6:	8526                	mv	a0,s1
    80001bb8:	60e2                	ld	ra,24(sp)
    80001bba:	6442                	ld	s0,16(sp)
    80001bbc:	64a2                	ld	s1,8(sp)
    80001bbe:	6902                	ld	s2,0(sp)
    80001bc0:	6105                	addi	sp,sp,32
    80001bc2:	8082                	ret
    uvmfree(pagetable, 0);
    80001bc4:	4581                	li	a1,0
    80001bc6:	8526                	mv	a0,s1
    80001bc8:	00000097          	auipc	ra,0x0
    80001bcc:	a8c080e7          	jalr	-1396(ra) # 80001654 <uvmfree>
    return 0;
    80001bd0:	4481                	li	s1,0
    80001bd2:	b7d5                	j	80001bb6 <proc_pagetable+0x58>
    uvmunmap(pagetable, TRAMPOLINE, 1, 0);
    80001bd4:	4681                	li	a3,0
    80001bd6:	4605                	li	a2,1
    80001bd8:	040005b7          	lui	a1,0x4000
    80001bdc:	15fd                	addi	a1,a1,-1
    80001bde:	05b2                	slli	a1,a1,0xc
    80001be0:	8526                	mv	a0,s1
    80001be2:	fffff097          	auipc	ra,0xfffff
    80001be6:	7d2080e7          	jalr	2002(ra) # 800013b4 <uvmunmap>
    uvmfree(pagetable, 0);
    80001bea:	4581                	li	a1,0
    80001bec:	8526                	mv	a0,s1
    80001bee:	00000097          	auipc	ra,0x0
    80001bf2:	a66080e7          	jalr	-1434(ra) # 80001654 <uvmfree>
    return 0;
    80001bf6:	4481                	li	s1,0
    80001bf8:	bf7d                	j	80001bb6 <proc_pagetable+0x58>

0000000080001bfa <proc_freepagetable>:
{
    80001bfa:	1101                	addi	sp,sp,-32
    80001bfc:	ec06                	sd	ra,24(sp)
    80001bfe:	e822                	sd	s0,16(sp)
    80001c00:	e426                	sd	s1,8(sp)
    80001c02:	e04a                	sd	s2,0(sp)
    80001c04:	1000                	addi	s0,sp,32
    80001c06:	84aa                	mv	s1,a0
    80001c08:	892e                	mv	s2,a1
  uvmunmap(pagetable, TRAMPOLINE, 1, 0);
    80001c0a:	4681                	li	a3,0
    80001c0c:	4605                	li	a2,1
    80001c0e:	040005b7          	lui	a1,0x4000
    80001c12:	15fd                	addi	a1,a1,-1
    80001c14:	05b2                	slli	a1,a1,0xc
    80001c16:	fffff097          	auipc	ra,0xfffff
    80001c1a:	79e080e7          	jalr	1950(ra) # 800013b4 <uvmunmap>
  uvmunmap(pagetable, TRAPFRAME, 1, 0);
    80001c1e:	4681                	li	a3,0
    80001c20:	4605                	li	a2,1
    80001c22:	020005b7          	lui	a1,0x2000
    80001c26:	15fd                	addi	a1,a1,-1
    80001c28:	05b6                	slli	a1,a1,0xd
    80001c2a:	8526                	mv	a0,s1
    80001c2c:	fffff097          	auipc	ra,0xfffff
    80001c30:	788080e7          	jalr	1928(ra) # 800013b4 <uvmunmap>
  uvmfree(pagetable, sz);
    80001c34:	85ca                	mv	a1,s2
    80001c36:	8526                	mv	a0,s1
    80001c38:	00000097          	auipc	ra,0x0
    80001c3c:	a1c080e7          	jalr	-1508(ra) # 80001654 <uvmfree>
}
    80001c40:	60e2                	ld	ra,24(sp)
    80001c42:	6442                	ld	s0,16(sp)
    80001c44:	64a2                	ld	s1,8(sp)
    80001c46:	6902                	ld	s2,0(sp)
    80001c48:	6105                	addi	sp,sp,32
    80001c4a:	8082                	ret

0000000080001c4c <freeproc>:
{
    80001c4c:	1101                	addi	sp,sp,-32
    80001c4e:	ec06                	sd	ra,24(sp)
    80001c50:	e822                	sd	s0,16(sp)
    80001c52:	e426                	sd	s1,8(sp)
    80001c54:	1000                	addi	s0,sp,32
    80001c56:	84aa                	mv	s1,a0
  if(p->trapframe)
    80001c58:	6d28                	ld	a0,88(a0)
    80001c5a:	c509                	beqz	a0,80001c64 <freeproc+0x18>
    kfree((void*)p->trapframe);
    80001c5c:	fffff097          	auipc	ra,0xfffff
    80001c60:	e16080e7          	jalr	-490(ra) # 80000a72 <kfree>
  p->trapframe = 0;
    80001c64:	0404bc23          	sd	zero,88(s1)
  if(p->pagetable)
    80001c68:	68a8                	ld	a0,80(s1)
    80001c6a:	c511                	beqz	a0,80001c76 <freeproc+0x2a>
    proc_freepagetable(p->pagetable, p->sz);
    80001c6c:	64ac                	ld	a1,72(s1)
    80001c6e:	00000097          	auipc	ra,0x0
    80001c72:	f8c080e7          	jalr	-116(ra) # 80001bfa <proc_freepagetable>
  p->pagetable = 0;
    80001c76:	0404b823          	sd	zero,80(s1)
  p->sz = 0;
    80001c7a:	0404b423          	sd	zero,72(s1)
  p->pid = 0;
    80001c7e:	0204ac23          	sw	zero,56(s1)
  p->parent = 0;
    80001c82:	0204b023          	sd	zero,32(s1)
  p->name[0] = 0;
    80001c86:	14048c23          	sb	zero,344(s1)
  p->chan = 0;
    80001c8a:	0204b423          	sd	zero,40(s1)
  p->killed = 0;
    80001c8e:	0204a823          	sw	zero,48(s1)
  p->xstate = 0;
    80001c92:	0204aa23          	sw	zero,52(s1)
  p->state = UNUSED;
    80001c96:	0004ac23          	sw	zero,24(s1)
}
    80001c9a:	60e2                	ld	ra,24(sp)
    80001c9c:	6442                	ld	s0,16(sp)
    80001c9e:	64a2                	ld	s1,8(sp)
    80001ca0:	6105                	addi	sp,sp,32
    80001ca2:	8082                	ret

0000000080001ca4 <allocproc>:
{
    80001ca4:	1101                	addi	sp,sp,-32
    80001ca6:	ec06                	sd	ra,24(sp)
    80001ca8:	e822                	sd	s0,16(sp)
    80001caa:	e426                	sd	s1,8(sp)
    80001cac:	e04a                	sd	s2,0(sp)
    80001cae:	1000                	addi	s0,sp,32
  for(p = proc; p < &proc[NPROC]; p++) {
    80001cb0:	00010497          	auipc	s1,0x10
    80001cb4:	0b848493          	addi	s1,s1,184 # 80011d68 <proc>
    80001cb8:	00016917          	auipc	s2,0x16
    80001cbc:	ab090913          	addi	s2,s2,-1360 # 80017768 <tickslock>
    acquire(&p->lock);
    80001cc0:	8526                	mv	a0,s1
    80001cc2:	fffff097          	auipc	ra,0xfffff
    80001cc6:	fa0080e7          	jalr	-96(ra) # 80000c62 <acquire>
    if(p->state == UNUSED) {
    80001cca:	4c9c                	lw	a5,24(s1)
    80001ccc:	cf81                	beqz	a5,80001ce4 <allocproc+0x40>
      release(&p->lock);
    80001cce:	8526                	mv	a0,s1
    80001cd0:	fffff097          	auipc	ra,0xfffff
    80001cd4:	046080e7          	jalr	70(ra) # 80000d16 <release>
  for(p = proc; p < &proc[NPROC]; p++) {
    80001cd8:	16848493          	addi	s1,s1,360
    80001cdc:	ff2492e3          	bne	s1,s2,80001cc0 <allocproc+0x1c>
  return 0;
    80001ce0:	4481                	li	s1,0
    80001ce2:	a0b9                	j	80001d30 <allocproc+0x8c>
  p->pid = allocpid();
    80001ce4:	00000097          	auipc	ra,0x0
    80001ce8:	e34080e7          	jalr	-460(ra) # 80001b18 <allocpid>
    80001cec:	dc88                	sw	a0,56(s1)
  if((p->trapframe = (struct trapframe *)kalloc()) == 0){
    80001cee:	fffff097          	auipc	ra,0xfffff
    80001cf2:	e84080e7          	jalr	-380(ra) # 80000b72 <kalloc>
    80001cf6:	892a                	mv	s2,a0
    80001cf8:	eca8                	sd	a0,88(s1)
    80001cfa:	c131                	beqz	a0,80001d3e <allocproc+0x9a>
  p->pagetable = proc_pagetable(p);
    80001cfc:	8526                	mv	a0,s1
    80001cfe:	00000097          	auipc	ra,0x0
    80001d02:	e60080e7          	jalr	-416(ra) # 80001b5e <proc_pagetable>
    80001d06:	892a                	mv	s2,a0
    80001d08:	e8a8                	sd	a0,80(s1)
  if(p->pagetable == 0){
    80001d0a:	c129                	beqz	a0,80001d4c <allocproc+0xa8>
  memset(&p->context, 0, sizeof(p->context));
    80001d0c:	07000613          	li	a2,112
    80001d10:	4581                	li	a1,0
    80001d12:	06048513          	addi	a0,s1,96
    80001d16:	fffff097          	auipc	ra,0xfffff
    80001d1a:	048080e7          	jalr	72(ra) # 80000d5e <memset>
  p->context.ra = (uint64)forkret;
    80001d1e:	00000797          	auipc	a5,0x0
    80001d22:	db278793          	addi	a5,a5,-590 # 80001ad0 <forkret>
    80001d26:	f0bc                	sd	a5,96(s1)
  p->context.sp = p->kstack + PGSIZE;
    80001d28:	60bc                	ld	a5,64(s1)
    80001d2a:	6705                	lui	a4,0x1
    80001d2c:	97ba                	add	a5,a5,a4
    80001d2e:	f4bc                	sd	a5,104(s1)
}
    80001d30:	8526                	mv	a0,s1
    80001d32:	60e2                	ld	ra,24(sp)
    80001d34:	6442                	ld	s0,16(sp)
    80001d36:	64a2                	ld	s1,8(sp)
    80001d38:	6902                	ld	s2,0(sp)
    80001d3a:	6105                	addi	sp,sp,32
    80001d3c:	8082                	ret
    release(&p->lock);
    80001d3e:	8526                	mv	a0,s1
    80001d40:	fffff097          	auipc	ra,0xfffff
    80001d44:	fd6080e7          	jalr	-42(ra) # 80000d16 <release>
    return 0;
    80001d48:	84ca                	mv	s1,s2
    80001d4a:	b7dd                	j	80001d30 <allocproc+0x8c>
    freeproc(p);
    80001d4c:	8526                	mv	a0,s1
    80001d4e:	00000097          	auipc	ra,0x0
    80001d52:	efe080e7          	jalr	-258(ra) # 80001c4c <freeproc>
    release(&p->lock);
    80001d56:	8526                	mv	a0,s1
    80001d58:	fffff097          	auipc	ra,0xfffff
    80001d5c:	fbe080e7          	jalr	-66(ra) # 80000d16 <release>
    return 0;
    80001d60:	84ca                	mv	s1,s2
    80001d62:	b7f9                	j	80001d30 <allocproc+0x8c>

0000000080001d64 <userinit>:
{
    80001d64:	1101                	addi	sp,sp,-32
    80001d66:	ec06                	sd	ra,24(sp)
    80001d68:	e822                	sd	s0,16(sp)
    80001d6a:	e426                	sd	s1,8(sp)
    80001d6c:	1000                	addi	s0,sp,32
  p = allocproc();
    80001d6e:	00000097          	auipc	ra,0x0
    80001d72:	f36080e7          	jalr	-202(ra) # 80001ca4 <allocproc>
    80001d76:	84aa                	mv	s1,a0
  initproc = p;
    80001d78:	00007797          	auipc	a5,0x7
    80001d7c:	2aa7b023          	sd	a0,672(a5) # 80009018 <initproc>
  uvminit(p->pagetable, initcode, sizeof(initcode));
    80001d80:	03400613          	li	a2,52
    80001d84:	00007597          	auipc	a1,0x7
    80001d88:	a3c58593          	addi	a1,a1,-1476 # 800087c0 <initcode>
    80001d8c:	6928                	ld	a0,80(a0)
    80001d8e:	fffff097          	auipc	ra,0xfffff
    80001d92:	6fa080e7          	jalr	1786(ra) # 80001488 <uvminit>
  p->sz = PGSIZE;
    80001d96:	6785                	lui	a5,0x1
    80001d98:	e4bc                	sd	a5,72(s1)
  p->trapframe->epc = 0;      // user program counter
    80001d9a:	6cb8                	ld	a4,88(s1)
    80001d9c:	00073c23          	sd	zero,24(a4) # 1018 <_entry-0x7fffefe8>
  p->trapframe->sp = PGSIZE;  // user stack pointer
    80001da0:	6cb8                	ld	a4,88(s1)
    80001da2:	fb1c                	sd	a5,48(a4)
  safestrcpy(p->name, "initcode", sizeof(p->name));
    80001da4:	4641                	li	a2,16
    80001da6:	00006597          	auipc	a1,0x6
    80001daa:	40258593          	addi	a1,a1,1026 # 800081a8 <states.1722+0x48>
    80001dae:	15848513          	addi	a0,s1,344
    80001db2:	fffff097          	auipc	ra,0xfffff
    80001db6:	124080e7          	jalr	292(ra) # 80000ed6 <safestrcpy>
  p->cwd = namei("/");
    80001dba:	00006517          	auipc	a0,0x6
    80001dbe:	3fe50513          	addi	a0,a0,1022 # 800081b8 <states.1722+0x58>
    80001dc2:	00002097          	auipc	ra,0x2
    80001dc6:	1cc080e7          	jalr	460(ra) # 80003f8e <namei>
    80001dca:	14a4b823          	sd	a0,336(s1)
  p->state = RUNNABLE;
    80001dce:	4789                	li	a5,2
    80001dd0:	cc9c                	sw	a5,24(s1)
  release(&p->lock);
    80001dd2:	8526                	mv	a0,s1
    80001dd4:	fffff097          	auipc	ra,0xfffff
    80001dd8:	f42080e7          	jalr	-190(ra) # 80000d16 <release>
}
    80001ddc:	60e2                	ld	ra,24(sp)
    80001dde:	6442                	ld	s0,16(sp)
    80001de0:	64a2                	ld	s1,8(sp)
    80001de2:	6105                	addi	sp,sp,32
    80001de4:	8082                	ret

0000000080001de6 <growproc>:
{
    80001de6:	1101                	addi	sp,sp,-32
    80001de8:	ec06                	sd	ra,24(sp)
    80001dea:	e822                	sd	s0,16(sp)
    80001dec:	e426                	sd	s1,8(sp)
    80001dee:	e04a                	sd	s2,0(sp)
    80001df0:	1000                	addi	s0,sp,32
    80001df2:	84aa                	mv	s1,a0
  struct proc *p = myproc();
    80001df4:	00000097          	auipc	ra,0x0
    80001df8:	ca4080e7          	jalr	-860(ra) # 80001a98 <myproc>
    80001dfc:	892a                	mv	s2,a0
  sz = p->sz;
    80001dfe:	652c                	ld	a1,72(a0)
    80001e00:	0005851b          	sext.w	a0,a1
  if(n > 0){
    80001e04:	00904f63          	bgtz	s1,80001e22 <growproc+0x3c>
  } else if(n < 0){
    80001e08:	0204cd63          	bltz	s1,80001e42 <growproc+0x5c>
  p->sz = sz;
    80001e0c:	1502                	slli	a0,a0,0x20
    80001e0e:	9101                	srli	a0,a0,0x20
    80001e10:	04a93423          	sd	a0,72(s2)
  return 0;
    80001e14:	4501                	li	a0,0
}
    80001e16:	60e2                	ld	ra,24(sp)
    80001e18:	6442                	ld	s0,16(sp)
    80001e1a:	64a2                	ld	s1,8(sp)
    80001e1c:	6902                	ld	s2,0(sp)
    80001e1e:	6105                	addi	sp,sp,32
    80001e20:	8082                	ret
    if((sz = uvmalloc(p->pagetable, sz, sz + n)) == 0) {
    80001e22:	00a4863b          	addw	a2,s1,a0
    80001e26:	1602                	slli	a2,a2,0x20
    80001e28:	9201                	srli	a2,a2,0x20
    80001e2a:	1582                	slli	a1,a1,0x20
    80001e2c:	9181                	srli	a1,a1,0x20
    80001e2e:	05093503          	ld	a0,80(s2)
    80001e32:	fffff097          	auipc	ra,0xfffff
    80001e36:	70e080e7          	jalr	1806(ra) # 80001540 <uvmalloc>
    80001e3a:	2501                	sext.w	a0,a0
    80001e3c:	f961                	bnez	a0,80001e0c <growproc+0x26>
      return -1;
    80001e3e:	557d                	li	a0,-1
    80001e40:	bfd9                	j	80001e16 <growproc+0x30>
    sz = uvmdealloc(p->pagetable, sz, sz + n);
    80001e42:	00a4863b          	addw	a2,s1,a0
    80001e46:	1602                	slli	a2,a2,0x20
    80001e48:	9201                	srli	a2,a2,0x20
    80001e4a:	1582                	slli	a1,a1,0x20
    80001e4c:	9181                	srli	a1,a1,0x20
    80001e4e:	05093503          	ld	a0,80(s2)
    80001e52:	fffff097          	auipc	ra,0xfffff
    80001e56:	6a8080e7          	jalr	1704(ra) # 800014fa <uvmdealloc>
    80001e5a:	2501                	sext.w	a0,a0
    80001e5c:	bf45                	j	80001e0c <growproc+0x26>

0000000080001e5e <fork>:
{
    80001e5e:	7179                	addi	sp,sp,-48
    80001e60:	f406                	sd	ra,40(sp)
    80001e62:	f022                	sd	s0,32(sp)
    80001e64:	ec26                	sd	s1,24(sp)
    80001e66:	e84a                	sd	s2,16(sp)
    80001e68:	e44e                	sd	s3,8(sp)
    80001e6a:	e052                	sd	s4,0(sp)
    80001e6c:	1800                	addi	s0,sp,48
  struct proc *p = myproc();
    80001e6e:	00000097          	auipc	ra,0x0
    80001e72:	c2a080e7          	jalr	-982(ra) # 80001a98 <myproc>
    80001e76:	892a                	mv	s2,a0
  if((np = allocproc()) == 0){
    80001e78:	00000097          	auipc	ra,0x0
    80001e7c:	e2c080e7          	jalr	-468(ra) # 80001ca4 <allocproc>
    80001e80:	c175                	beqz	a0,80001f64 <fork+0x106>
    80001e82:	89aa                	mv	s3,a0
  if(uvmcopy(p->pagetable, np->pagetable, p->sz) < 0){
    80001e84:	04893603          	ld	a2,72(s2)
    80001e88:	692c                	ld	a1,80(a0)
    80001e8a:	05093503          	ld	a0,80(s2)
    80001e8e:	fffff097          	auipc	ra,0xfffff
    80001e92:	7fe080e7          	jalr	2046(ra) # 8000168c <uvmcopy>
    80001e96:	04054863          	bltz	a0,80001ee6 <fork+0x88>
  np->sz = p->sz;
    80001e9a:	04893783          	ld	a5,72(s2)
    80001e9e:	04f9b423          	sd	a5,72(s3) # 4000048 <_entry-0x7bffffb8>
  np->parent = p;
    80001ea2:	0329b023          	sd	s2,32(s3)
  *(np->trapframe) = *(p->trapframe);
    80001ea6:	05893683          	ld	a3,88(s2)
    80001eaa:	87b6                	mv	a5,a3
    80001eac:	0589b703          	ld	a4,88(s3)
    80001eb0:	12068693          	addi	a3,a3,288
    80001eb4:	0007b803          	ld	a6,0(a5) # 1000 <_entry-0x7ffff000>
    80001eb8:	6788                	ld	a0,8(a5)
    80001eba:	6b8c                	ld	a1,16(a5)
    80001ebc:	6f90                	ld	a2,24(a5)
    80001ebe:	01073023          	sd	a6,0(a4)
    80001ec2:	e708                	sd	a0,8(a4)
    80001ec4:	eb0c                	sd	a1,16(a4)
    80001ec6:	ef10                	sd	a2,24(a4)
    80001ec8:	02078793          	addi	a5,a5,32
    80001ecc:	02070713          	addi	a4,a4,32
    80001ed0:	fed792e3          	bne	a5,a3,80001eb4 <fork+0x56>
  np->trapframe->a0 = 0;
    80001ed4:	0589b783          	ld	a5,88(s3)
    80001ed8:	0607b823          	sd	zero,112(a5)
    80001edc:	0d000493          	li	s1,208
  for(i = 0; i < NOFILE; i++)
    80001ee0:	15000a13          	li	s4,336
    80001ee4:	a03d                	j	80001f12 <fork+0xb4>
    freeproc(np);
    80001ee6:	854e                	mv	a0,s3
    80001ee8:	00000097          	auipc	ra,0x0
    80001eec:	d64080e7          	jalr	-668(ra) # 80001c4c <freeproc>
    release(&np->lock);
    80001ef0:	854e                	mv	a0,s3
    80001ef2:	fffff097          	auipc	ra,0xfffff
    80001ef6:	e24080e7          	jalr	-476(ra) # 80000d16 <release>
    return -1;
    80001efa:	54fd                	li	s1,-1
    80001efc:	a899                	j	80001f52 <fork+0xf4>
      np->ofile[i] = filedup(p->ofile[i]);
    80001efe:	00002097          	auipc	ra,0x2
    80001f02:	74e080e7          	jalr	1870(ra) # 8000464c <filedup>
    80001f06:	009987b3          	add	a5,s3,s1
    80001f0a:	e388                	sd	a0,0(a5)
  for(i = 0; i < NOFILE; i++)
    80001f0c:	04a1                	addi	s1,s1,8
    80001f0e:	01448763          	beq	s1,s4,80001f1c <fork+0xbe>
    if(p->ofile[i])
    80001f12:	009907b3          	add	a5,s2,s1
    80001f16:	6388                	ld	a0,0(a5)
    80001f18:	f17d                	bnez	a0,80001efe <fork+0xa0>
    80001f1a:	bfcd                	j	80001f0c <fork+0xae>
  np->cwd = idup(p->cwd);
    80001f1c:	15093503          	ld	a0,336(s2)
    80001f20:	00002097          	auipc	ra,0x2
    80001f24:	872080e7          	jalr	-1934(ra) # 80003792 <idup>
    80001f28:	14a9b823          	sd	a0,336(s3)
  safestrcpy(np->name, p->name, sizeof(p->name));
    80001f2c:	4641                	li	a2,16
    80001f2e:	15890593          	addi	a1,s2,344
    80001f32:	15898513          	addi	a0,s3,344
    80001f36:	fffff097          	auipc	ra,0xfffff
    80001f3a:	fa0080e7          	jalr	-96(ra) # 80000ed6 <safestrcpy>
  pid = np->pid;
    80001f3e:	0389a483          	lw	s1,56(s3)
  np->state = RUNNABLE;
    80001f42:	4789                	li	a5,2
    80001f44:	00f9ac23          	sw	a5,24(s3)
  release(&np->lock);
    80001f48:	854e                	mv	a0,s3
    80001f4a:	fffff097          	auipc	ra,0xfffff
    80001f4e:	dcc080e7          	jalr	-564(ra) # 80000d16 <release>
}
    80001f52:	8526                	mv	a0,s1
    80001f54:	70a2                	ld	ra,40(sp)
    80001f56:	7402                	ld	s0,32(sp)
    80001f58:	64e2                	ld	s1,24(sp)
    80001f5a:	6942                	ld	s2,16(sp)
    80001f5c:	69a2                	ld	s3,8(sp)
    80001f5e:	6a02                	ld	s4,0(sp)
    80001f60:	6145                	addi	sp,sp,48
    80001f62:	8082                	ret
    return -1;
    80001f64:	54fd                	li	s1,-1
    80001f66:	b7f5                	j	80001f52 <fork+0xf4>

0000000080001f68 <reparent>:
{
    80001f68:	7179                	addi	sp,sp,-48
    80001f6a:	f406                	sd	ra,40(sp)
    80001f6c:	f022                	sd	s0,32(sp)
    80001f6e:	ec26                	sd	s1,24(sp)
    80001f70:	e84a                	sd	s2,16(sp)
    80001f72:	e44e                	sd	s3,8(sp)
    80001f74:	e052                	sd	s4,0(sp)
    80001f76:	1800                	addi	s0,sp,48
    80001f78:	89aa                	mv	s3,a0
  for(pp = proc; pp < &proc[NPROC]; pp++){
    80001f7a:	00010497          	auipc	s1,0x10
    80001f7e:	dee48493          	addi	s1,s1,-530 # 80011d68 <proc>
      pp->parent = initproc;
    80001f82:	00007a17          	auipc	s4,0x7
    80001f86:	096a0a13          	addi	s4,s4,150 # 80009018 <initproc>
  for(pp = proc; pp < &proc[NPROC]; pp++){
    80001f8a:	00015917          	auipc	s2,0x15
    80001f8e:	7de90913          	addi	s2,s2,2014 # 80017768 <tickslock>
    80001f92:	a029                	j	80001f9c <reparent+0x34>
    80001f94:	16848493          	addi	s1,s1,360
    80001f98:	03248363          	beq	s1,s2,80001fbe <reparent+0x56>
    if(pp->parent == p){
    80001f9c:	709c                	ld	a5,32(s1)
    80001f9e:	ff379be3          	bne	a5,s3,80001f94 <reparent+0x2c>
      acquire(&pp->lock);
    80001fa2:	8526                	mv	a0,s1
    80001fa4:	fffff097          	auipc	ra,0xfffff
    80001fa8:	cbe080e7          	jalr	-834(ra) # 80000c62 <acquire>
      pp->parent = initproc;
    80001fac:	000a3783          	ld	a5,0(s4)
    80001fb0:	f09c                	sd	a5,32(s1)
      release(&pp->lock);
    80001fb2:	8526                	mv	a0,s1
    80001fb4:	fffff097          	auipc	ra,0xfffff
    80001fb8:	d62080e7          	jalr	-670(ra) # 80000d16 <release>
    80001fbc:	bfe1                	j	80001f94 <reparent+0x2c>
}
    80001fbe:	70a2                	ld	ra,40(sp)
    80001fc0:	7402                	ld	s0,32(sp)
    80001fc2:	64e2                	ld	s1,24(sp)
    80001fc4:	6942                	ld	s2,16(sp)
    80001fc6:	69a2                	ld	s3,8(sp)
    80001fc8:	6a02                	ld	s4,0(sp)
    80001fca:	6145                	addi	sp,sp,48
    80001fcc:	8082                	ret

0000000080001fce <scheduler>:
{
    80001fce:	711d                	addi	sp,sp,-96
    80001fd0:	ec86                	sd	ra,88(sp)
    80001fd2:	e8a2                	sd	s0,80(sp)
    80001fd4:	e4a6                	sd	s1,72(sp)
    80001fd6:	e0ca                	sd	s2,64(sp)
    80001fd8:	fc4e                	sd	s3,56(sp)
    80001fda:	f852                	sd	s4,48(sp)
    80001fdc:	f456                	sd	s5,40(sp)
    80001fde:	f05a                	sd	s6,32(sp)
    80001fe0:	ec5e                	sd	s7,24(sp)
    80001fe2:	e862                	sd	s8,16(sp)
    80001fe4:	e466                	sd	s9,8(sp)
    80001fe6:	1080                	addi	s0,sp,96
    80001fe8:	8792                	mv	a5,tp
  int id = r_tp();
    80001fea:	2781                	sext.w	a5,a5
  c->proc = 0;
    80001fec:	00779c13          	slli	s8,a5,0x7
    80001ff0:	00010717          	auipc	a4,0x10
    80001ff4:	96070713          	addi	a4,a4,-1696 # 80011950 <pid_lock>
    80001ff8:	9762                	add	a4,a4,s8
    80001ffa:	00073c23          	sd	zero,24(a4)
        swtch(&c->context, &p->context);
    80001ffe:	00010717          	auipc	a4,0x10
    80002002:	97270713          	addi	a4,a4,-1678 # 80011970 <cpus+0x8>
    80002006:	9c3a                	add	s8,s8,a4
      if(p->state == RUNNABLE) {
    80002008:	4a89                	li	s5,2
        c->proc = p;
    8000200a:	079e                	slli	a5,a5,0x7
    8000200c:	00010b17          	auipc	s6,0x10
    80002010:	944b0b13          	addi	s6,s6,-1724 # 80011950 <pid_lock>
    80002014:	9b3e                	add	s6,s6,a5
    for(p = proc; p < &proc[NPROC]; p++) {
    80002016:	00015a17          	auipc	s4,0x15
    8000201a:	752a0a13          	addi	s4,s4,1874 # 80017768 <tickslock>
    int nproc = 0;
    8000201e:	4c81                	li	s9,0
    80002020:	a8a1                	j	80002078 <scheduler+0xaa>
        p->state = RUNNING;
    80002022:	0174ac23          	sw	s7,24(s1)
        c->proc = p;
    80002026:	009b3c23          	sd	s1,24(s6)
        swtch(&c->context, &p->context);
    8000202a:	06048593          	addi	a1,s1,96
    8000202e:	8562                	mv	a0,s8
    80002030:	00000097          	auipc	ra,0x0
    80002034:	640080e7          	jalr	1600(ra) # 80002670 <swtch>
        c->proc = 0;
    80002038:	000b3c23          	sd	zero,24(s6)
      release(&p->lock);
    8000203c:	8526                	mv	a0,s1
    8000203e:	fffff097          	auipc	ra,0xfffff
    80002042:	cd8080e7          	jalr	-808(ra) # 80000d16 <release>
    for(p = proc; p < &proc[NPROC]; p++) {
    80002046:	16848493          	addi	s1,s1,360
    8000204a:	01448d63          	beq	s1,s4,80002064 <scheduler+0x96>
      acquire(&p->lock);
    8000204e:	8526                	mv	a0,s1
    80002050:	fffff097          	auipc	ra,0xfffff
    80002054:	c12080e7          	jalr	-1006(ra) # 80000c62 <acquire>
      if(p->state != UNUSED) {
    80002058:	4c9c                	lw	a5,24(s1)
    8000205a:	d3ed                	beqz	a5,8000203c <scheduler+0x6e>
        nproc++;
    8000205c:	2985                	addiw	s3,s3,1
      if(p->state == RUNNABLE) {
    8000205e:	fd579fe3          	bne	a5,s5,8000203c <scheduler+0x6e>
    80002062:	b7c1                	j	80002022 <scheduler+0x54>
    if(nproc <= 2) {   // only init and sh exist
    80002064:	013aca63          	blt	s5,s3,80002078 <scheduler+0xaa>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80002068:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() | SSTATUS_SIE);
    8000206c:	0027e793          	ori	a5,a5,2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80002070:	10079073          	csrw	sstatus,a5
      asm volatile("wfi");
    80002074:	10500073          	wfi
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80002078:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() | SSTATUS_SIE);
    8000207c:	0027e793          	ori	a5,a5,2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80002080:	10079073          	csrw	sstatus,a5
    int nproc = 0;
    80002084:	89e6                	mv	s3,s9
    for(p = proc; p < &proc[NPROC]; p++) {
    80002086:	00010497          	auipc	s1,0x10
    8000208a:	ce248493          	addi	s1,s1,-798 # 80011d68 <proc>
        p->state = RUNNING;
    8000208e:	4b8d                	li	s7,3
    80002090:	bf7d                	j	8000204e <scheduler+0x80>

0000000080002092 <sched>:
{
    80002092:	7179                	addi	sp,sp,-48
    80002094:	f406                	sd	ra,40(sp)
    80002096:	f022                	sd	s0,32(sp)
    80002098:	ec26                	sd	s1,24(sp)
    8000209a:	e84a                	sd	s2,16(sp)
    8000209c:	e44e                	sd	s3,8(sp)
    8000209e:	1800                	addi	s0,sp,48
  struct proc *p = myproc();
    800020a0:	00000097          	auipc	ra,0x0
    800020a4:	9f8080e7          	jalr	-1544(ra) # 80001a98 <myproc>
    800020a8:	892a                	mv	s2,a0
  if(!holding(&p->lock))
    800020aa:	fffff097          	auipc	ra,0xfffff
    800020ae:	b3e080e7          	jalr	-1218(ra) # 80000be8 <holding>
    800020b2:	cd25                	beqz	a0,8000212a <sched+0x98>
  asm volatile("mv %0, tp" : "=r" (x) );
    800020b4:	8792                	mv	a5,tp
  if(mycpu()->noff != 1)
    800020b6:	2781                	sext.w	a5,a5
    800020b8:	079e                	slli	a5,a5,0x7
    800020ba:	00010717          	auipc	a4,0x10
    800020be:	89670713          	addi	a4,a4,-1898 # 80011950 <pid_lock>
    800020c2:	97ba                	add	a5,a5,a4
    800020c4:	0907a703          	lw	a4,144(a5)
    800020c8:	4785                	li	a5,1
    800020ca:	06f71863          	bne	a4,a5,8000213a <sched+0xa8>
  if(p->state == RUNNING)
    800020ce:	01892703          	lw	a4,24(s2)
    800020d2:	478d                	li	a5,3
    800020d4:	06f70b63          	beq	a4,a5,8000214a <sched+0xb8>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    800020d8:	100027f3          	csrr	a5,sstatus
  return (x & SSTATUS_SIE) != 0;
    800020dc:	8b89                	andi	a5,a5,2
  if(intr_get())
    800020de:	efb5                	bnez	a5,8000215a <sched+0xc8>
  asm volatile("mv %0, tp" : "=r" (x) );
    800020e0:	8792                	mv	a5,tp
  intena = mycpu()->intena;
    800020e2:	00010497          	auipc	s1,0x10
    800020e6:	86e48493          	addi	s1,s1,-1938 # 80011950 <pid_lock>
    800020ea:	2781                	sext.w	a5,a5
    800020ec:	079e                	slli	a5,a5,0x7
    800020ee:	97a6                	add	a5,a5,s1
    800020f0:	0947a983          	lw	s3,148(a5)
    800020f4:	8792                	mv	a5,tp
  swtch(&p->context, &mycpu()->context);
    800020f6:	2781                	sext.w	a5,a5
    800020f8:	079e                	slli	a5,a5,0x7
    800020fa:	00010597          	auipc	a1,0x10
    800020fe:	87658593          	addi	a1,a1,-1930 # 80011970 <cpus+0x8>
    80002102:	95be                	add	a1,a1,a5
    80002104:	06090513          	addi	a0,s2,96
    80002108:	00000097          	auipc	ra,0x0
    8000210c:	568080e7          	jalr	1384(ra) # 80002670 <swtch>
    80002110:	8792                	mv	a5,tp
  mycpu()->intena = intena;
    80002112:	2781                	sext.w	a5,a5
    80002114:	079e                	slli	a5,a5,0x7
    80002116:	97a6                	add	a5,a5,s1
    80002118:	0937aa23          	sw	s3,148(a5)
}
    8000211c:	70a2                	ld	ra,40(sp)
    8000211e:	7402                	ld	s0,32(sp)
    80002120:	64e2                	ld	s1,24(sp)
    80002122:	6942                	ld	s2,16(sp)
    80002124:	69a2                	ld	s3,8(sp)
    80002126:	6145                	addi	sp,sp,48
    80002128:	8082                	ret
    panic("sched p->lock");
    8000212a:	00006517          	auipc	a0,0x6
    8000212e:	09650513          	addi	a0,a0,150 # 800081c0 <states.1722+0x60>
    80002132:	ffffe097          	auipc	ra,0xffffe
    80002136:	442080e7          	jalr	1090(ra) # 80000574 <panic>
    panic("sched locks");
    8000213a:	00006517          	auipc	a0,0x6
    8000213e:	09650513          	addi	a0,a0,150 # 800081d0 <states.1722+0x70>
    80002142:	ffffe097          	auipc	ra,0xffffe
    80002146:	432080e7          	jalr	1074(ra) # 80000574 <panic>
    panic("sched running");
    8000214a:	00006517          	auipc	a0,0x6
    8000214e:	09650513          	addi	a0,a0,150 # 800081e0 <states.1722+0x80>
    80002152:	ffffe097          	auipc	ra,0xffffe
    80002156:	422080e7          	jalr	1058(ra) # 80000574 <panic>
    panic("sched interruptible");
    8000215a:	00006517          	auipc	a0,0x6
    8000215e:	09650513          	addi	a0,a0,150 # 800081f0 <states.1722+0x90>
    80002162:	ffffe097          	auipc	ra,0xffffe
    80002166:	412080e7          	jalr	1042(ra) # 80000574 <panic>

000000008000216a <exit>:
{
    8000216a:	7179                	addi	sp,sp,-48
    8000216c:	f406                	sd	ra,40(sp)
    8000216e:	f022                	sd	s0,32(sp)
    80002170:	ec26                	sd	s1,24(sp)
    80002172:	e84a                	sd	s2,16(sp)
    80002174:	e44e                	sd	s3,8(sp)
    80002176:	e052                	sd	s4,0(sp)
    80002178:	1800                	addi	s0,sp,48
    8000217a:	8a2a                	mv	s4,a0
  struct proc *p = myproc();
    8000217c:	00000097          	auipc	ra,0x0
    80002180:	91c080e7          	jalr	-1764(ra) # 80001a98 <myproc>
    80002184:	89aa                	mv	s3,a0
  if(p == initproc)
    80002186:	00007797          	auipc	a5,0x7
    8000218a:	e9278793          	addi	a5,a5,-366 # 80009018 <initproc>
    8000218e:	639c                	ld	a5,0(a5)
    80002190:	0d050493          	addi	s1,a0,208
    80002194:	15050913          	addi	s2,a0,336
    80002198:	02a79363          	bne	a5,a0,800021be <exit+0x54>
    panic("init exiting");
    8000219c:	00006517          	auipc	a0,0x6
    800021a0:	06c50513          	addi	a0,a0,108 # 80008208 <states.1722+0xa8>
    800021a4:	ffffe097          	auipc	ra,0xffffe
    800021a8:	3d0080e7          	jalr	976(ra) # 80000574 <panic>
      fileclose(f);
    800021ac:	00002097          	auipc	ra,0x2
    800021b0:	4f2080e7          	jalr	1266(ra) # 8000469e <fileclose>
      p->ofile[fd] = 0;
    800021b4:	0004b023          	sd	zero,0(s1)
  for(int fd = 0; fd < NOFILE; fd++){
    800021b8:	04a1                	addi	s1,s1,8
    800021ba:	01248563          	beq	s1,s2,800021c4 <exit+0x5a>
    if(p->ofile[fd]){
    800021be:	6088                	ld	a0,0(s1)
    800021c0:	f575                	bnez	a0,800021ac <exit+0x42>
    800021c2:	bfdd                	j	800021b8 <exit+0x4e>
  begin_op();
    800021c4:	00002097          	auipc	ra,0x2
    800021c8:	fd8080e7          	jalr	-40(ra) # 8000419c <begin_op>
  iput(p->cwd);
    800021cc:	1509b503          	ld	a0,336(s3)
    800021d0:	00001097          	auipc	ra,0x1
    800021d4:	7bc080e7          	jalr	1980(ra) # 8000398c <iput>
  end_op();
    800021d8:	00002097          	auipc	ra,0x2
    800021dc:	044080e7          	jalr	68(ra) # 8000421c <end_op>
  p->cwd = 0;
    800021e0:	1409b823          	sd	zero,336(s3)
  acquire(&initproc->lock);
    800021e4:	00007497          	auipc	s1,0x7
    800021e8:	e3448493          	addi	s1,s1,-460 # 80009018 <initproc>
    800021ec:	6088                	ld	a0,0(s1)
    800021ee:	fffff097          	auipc	ra,0xfffff
    800021f2:	a74080e7          	jalr	-1420(ra) # 80000c62 <acquire>
  wakeup1(initproc);
    800021f6:	6088                	ld	a0,0(s1)
    800021f8:	fffff097          	auipc	ra,0xfffff
    800021fc:	760080e7          	jalr	1888(ra) # 80001958 <wakeup1>
  release(&initproc->lock);
    80002200:	6088                	ld	a0,0(s1)
    80002202:	fffff097          	auipc	ra,0xfffff
    80002206:	b14080e7          	jalr	-1260(ra) # 80000d16 <release>
  acquire(&p->lock);
    8000220a:	854e                	mv	a0,s3
    8000220c:	fffff097          	auipc	ra,0xfffff
    80002210:	a56080e7          	jalr	-1450(ra) # 80000c62 <acquire>
  struct proc *original_parent = p->parent;
    80002214:	0209b483          	ld	s1,32(s3)
  release(&p->lock);
    80002218:	854e                	mv	a0,s3
    8000221a:	fffff097          	auipc	ra,0xfffff
    8000221e:	afc080e7          	jalr	-1284(ra) # 80000d16 <release>
  acquire(&original_parent->lock);
    80002222:	8526                	mv	a0,s1
    80002224:	fffff097          	auipc	ra,0xfffff
    80002228:	a3e080e7          	jalr	-1474(ra) # 80000c62 <acquire>
  acquire(&p->lock);
    8000222c:	854e                	mv	a0,s3
    8000222e:	fffff097          	auipc	ra,0xfffff
    80002232:	a34080e7          	jalr	-1484(ra) # 80000c62 <acquire>
  reparent(p);
    80002236:	854e                	mv	a0,s3
    80002238:	00000097          	auipc	ra,0x0
    8000223c:	d30080e7          	jalr	-720(ra) # 80001f68 <reparent>
  wakeup1(original_parent);
    80002240:	8526                	mv	a0,s1
    80002242:	fffff097          	auipc	ra,0xfffff
    80002246:	716080e7          	jalr	1814(ra) # 80001958 <wakeup1>
  p->xstate = status;
    8000224a:	0349aa23          	sw	s4,52(s3)
  p->state = ZOMBIE;
    8000224e:	4791                	li	a5,4
    80002250:	00f9ac23          	sw	a5,24(s3)
  release(&original_parent->lock);
    80002254:	8526                	mv	a0,s1
    80002256:	fffff097          	auipc	ra,0xfffff
    8000225a:	ac0080e7          	jalr	-1344(ra) # 80000d16 <release>
  sched();
    8000225e:	00000097          	auipc	ra,0x0
    80002262:	e34080e7          	jalr	-460(ra) # 80002092 <sched>
  panic("zombie exit");
    80002266:	00006517          	auipc	a0,0x6
    8000226a:	fb250513          	addi	a0,a0,-78 # 80008218 <states.1722+0xb8>
    8000226e:	ffffe097          	auipc	ra,0xffffe
    80002272:	306080e7          	jalr	774(ra) # 80000574 <panic>

0000000080002276 <yield>:
{
    80002276:	1101                	addi	sp,sp,-32
    80002278:	ec06                	sd	ra,24(sp)
    8000227a:	e822                	sd	s0,16(sp)
    8000227c:	e426                	sd	s1,8(sp)
    8000227e:	1000                	addi	s0,sp,32
  struct proc *p = myproc();
    80002280:	00000097          	auipc	ra,0x0
    80002284:	818080e7          	jalr	-2024(ra) # 80001a98 <myproc>
    80002288:	84aa                	mv	s1,a0
  acquire(&p->lock);
    8000228a:	fffff097          	auipc	ra,0xfffff
    8000228e:	9d8080e7          	jalr	-1576(ra) # 80000c62 <acquire>
  p->state = RUNNABLE;
    80002292:	4789                	li	a5,2
    80002294:	cc9c                	sw	a5,24(s1)
  sched();
    80002296:	00000097          	auipc	ra,0x0
    8000229a:	dfc080e7          	jalr	-516(ra) # 80002092 <sched>
  release(&p->lock);
    8000229e:	8526                	mv	a0,s1
    800022a0:	fffff097          	auipc	ra,0xfffff
    800022a4:	a76080e7          	jalr	-1418(ra) # 80000d16 <release>
}
    800022a8:	60e2                	ld	ra,24(sp)
    800022aa:	6442                	ld	s0,16(sp)
    800022ac:	64a2                	ld	s1,8(sp)
    800022ae:	6105                	addi	sp,sp,32
    800022b0:	8082                	ret

00000000800022b2 <sleep>:
{
    800022b2:	7179                	addi	sp,sp,-48
    800022b4:	f406                	sd	ra,40(sp)
    800022b6:	f022                	sd	s0,32(sp)
    800022b8:	ec26                	sd	s1,24(sp)
    800022ba:	e84a                	sd	s2,16(sp)
    800022bc:	e44e                	sd	s3,8(sp)
    800022be:	1800                	addi	s0,sp,48
    800022c0:	89aa                	mv	s3,a0
    800022c2:	892e                	mv	s2,a1
  struct proc *p = myproc();
    800022c4:	fffff097          	auipc	ra,0xfffff
    800022c8:	7d4080e7          	jalr	2004(ra) # 80001a98 <myproc>
    800022cc:	84aa                	mv	s1,a0
  if(lk != &p->lock){  //DOC: sleeplock0
    800022ce:	05250663          	beq	a0,s2,8000231a <sleep+0x68>
    acquire(&p->lock);  //DOC: sleeplock1
    800022d2:	fffff097          	auipc	ra,0xfffff
    800022d6:	990080e7          	jalr	-1648(ra) # 80000c62 <acquire>
    release(lk);
    800022da:	854a                	mv	a0,s2
    800022dc:	fffff097          	auipc	ra,0xfffff
    800022e0:	a3a080e7          	jalr	-1478(ra) # 80000d16 <release>
  p->chan = chan;
    800022e4:	0334b423          	sd	s3,40(s1)
  p->state = SLEEPING;
    800022e8:	4785                	li	a5,1
    800022ea:	cc9c                	sw	a5,24(s1)
  sched();
    800022ec:	00000097          	auipc	ra,0x0
    800022f0:	da6080e7          	jalr	-602(ra) # 80002092 <sched>
  p->chan = 0;
    800022f4:	0204b423          	sd	zero,40(s1)
    release(&p->lock);
    800022f8:	8526                	mv	a0,s1
    800022fa:	fffff097          	auipc	ra,0xfffff
    800022fe:	a1c080e7          	jalr	-1508(ra) # 80000d16 <release>
    acquire(lk);
    80002302:	854a                	mv	a0,s2
    80002304:	fffff097          	auipc	ra,0xfffff
    80002308:	95e080e7          	jalr	-1698(ra) # 80000c62 <acquire>
}
    8000230c:	70a2                	ld	ra,40(sp)
    8000230e:	7402                	ld	s0,32(sp)
    80002310:	64e2                	ld	s1,24(sp)
    80002312:	6942                	ld	s2,16(sp)
    80002314:	69a2                	ld	s3,8(sp)
    80002316:	6145                	addi	sp,sp,48
    80002318:	8082                	ret
  p->chan = chan;
    8000231a:	03353423          	sd	s3,40(a0)
  p->state = SLEEPING;
    8000231e:	4785                	li	a5,1
    80002320:	cd1c                	sw	a5,24(a0)
  sched();
    80002322:	00000097          	auipc	ra,0x0
    80002326:	d70080e7          	jalr	-656(ra) # 80002092 <sched>
  p->chan = 0;
    8000232a:	0204b423          	sd	zero,40(s1)
  if(lk != &p->lock){
    8000232e:	bff9                	j	8000230c <sleep+0x5a>

0000000080002330 <wait>:
{
    80002330:	715d                	addi	sp,sp,-80
    80002332:	e486                	sd	ra,72(sp)
    80002334:	e0a2                	sd	s0,64(sp)
    80002336:	fc26                	sd	s1,56(sp)
    80002338:	f84a                	sd	s2,48(sp)
    8000233a:	f44e                	sd	s3,40(sp)
    8000233c:	f052                	sd	s4,32(sp)
    8000233e:	ec56                	sd	s5,24(sp)
    80002340:	e85a                	sd	s6,16(sp)
    80002342:	e45e                	sd	s7,8(sp)
    80002344:	e062                	sd	s8,0(sp)
    80002346:	0880                	addi	s0,sp,80
    80002348:	8baa                	mv	s7,a0
  struct proc *p = myproc();
    8000234a:	fffff097          	auipc	ra,0xfffff
    8000234e:	74e080e7          	jalr	1870(ra) # 80001a98 <myproc>
    80002352:	892a                	mv	s2,a0
  acquire(&p->lock);
    80002354:	8c2a                	mv	s8,a0
    80002356:	fffff097          	auipc	ra,0xfffff
    8000235a:	90c080e7          	jalr	-1780(ra) # 80000c62 <acquire>
    havekids = 0;
    8000235e:	4b01                	li	s6,0
        if(np->state == ZOMBIE){
    80002360:	4a11                	li	s4,4
    for(np = proc; np < &proc[NPROC]; np++){
    80002362:	00015997          	auipc	s3,0x15
    80002366:	40698993          	addi	s3,s3,1030 # 80017768 <tickslock>
        havekids = 1;
    8000236a:	4a85                	li	s5,1
    havekids = 0;
    8000236c:	875a                	mv	a4,s6
    for(np = proc; np < &proc[NPROC]; np++){
    8000236e:	00010497          	auipc	s1,0x10
    80002372:	9fa48493          	addi	s1,s1,-1542 # 80011d68 <proc>
    80002376:	a08d                	j	800023d8 <wait+0xa8>
          pid = np->pid;
    80002378:	0384a983          	lw	s3,56(s1)
          if(addr != 0 && copyout(p->pagetable, addr, (char *)&np->xstate,
    8000237c:	000b8e63          	beqz	s7,80002398 <wait+0x68>
    80002380:	4691                	li	a3,4
    80002382:	03448613          	addi	a2,s1,52
    80002386:	85de                	mv	a1,s7
    80002388:	05093503          	ld	a0,80(s2)
    8000238c:	fffff097          	auipc	ra,0xfffff
    80002390:	3e8080e7          	jalr	1000(ra) # 80001774 <copyout>
    80002394:	02054263          	bltz	a0,800023b8 <wait+0x88>
          freeproc(np);
    80002398:	8526                	mv	a0,s1
    8000239a:	00000097          	auipc	ra,0x0
    8000239e:	8b2080e7          	jalr	-1870(ra) # 80001c4c <freeproc>
          release(&np->lock);
    800023a2:	8526                	mv	a0,s1
    800023a4:	fffff097          	auipc	ra,0xfffff
    800023a8:	972080e7          	jalr	-1678(ra) # 80000d16 <release>
          release(&p->lock);
    800023ac:	854a                	mv	a0,s2
    800023ae:	fffff097          	auipc	ra,0xfffff
    800023b2:	968080e7          	jalr	-1688(ra) # 80000d16 <release>
          return pid;
    800023b6:	a8a9                	j	80002410 <wait+0xe0>
            release(&np->lock);
    800023b8:	8526                	mv	a0,s1
    800023ba:	fffff097          	auipc	ra,0xfffff
    800023be:	95c080e7          	jalr	-1700(ra) # 80000d16 <release>
            release(&p->lock);
    800023c2:	854a                	mv	a0,s2
    800023c4:	fffff097          	auipc	ra,0xfffff
    800023c8:	952080e7          	jalr	-1710(ra) # 80000d16 <release>
            return -1;
    800023cc:	59fd                	li	s3,-1
    800023ce:	a089                	j	80002410 <wait+0xe0>
    for(np = proc; np < &proc[NPROC]; np++){
    800023d0:	16848493          	addi	s1,s1,360
    800023d4:	03348463          	beq	s1,s3,800023fc <wait+0xcc>
      if(np->parent == p){
    800023d8:	709c                	ld	a5,32(s1)
    800023da:	ff279be3          	bne	a5,s2,800023d0 <wait+0xa0>
        acquire(&np->lock);
    800023de:	8526                	mv	a0,s1
    800023e0:	fffff097          	auipc	ra,0xfffff
    800023e4:	882080e7          	jalr	-1918(ra) # 80000c62 <acquire>
        if(np->state == ZOMBIE){
    800023e8:	4c9c                	lw	a5,24(s1)
    800023ea:	f94787e3          	beq	a5,s4,80002378 <wait+0x48>
        release(&np->lock);
    800023ee:	8526                	mv	a0,s1
    800023f0:	fffff097          	auipc	ra,0xfffff
    800023f4:	926080e7          	jalr	-1754(ra) # 80000d16 <release>
        havekids = 1;
    800023f8:	8756                	mv	a4,s5
    800023fa:	bfd9                	j	800023d0 <wait+0xa0>
    if(!havekids || p->killed){
    800023fc:	c701                	beqz	a4,80002404 <wait+0xd4>
    800023fe:	03092783          	lw	a5,48(s2)
    80002402:	c785                	beqz	a5,8000242a <wait+0xfa>
      release(&p->lock);
    80002404:	854a                	mv	a0,s2
    80002406:	fffff097          	auipc	ra,0xfffff
    8000240a:	910080e7          	jalr	-1776(ra) # 80000d16 <release>
      return -1;
    8000240e:	59fd                	li	s3,-1
}
    80002410:	854e                	mv	a0,s3
    80002412:	60a6                	ld	ra,72(sp)
    80002414:	6406                	ld	s0,64(sp)
    80002416:	74e2                	ld	s1,56(sp)
    80002418:	7942                	ld	s2,48(sp)
    8000241a:	79a2                	ld	s3,40(sp)
    8000241c:	7a02                	ld	s4,32(sp)
    8000241e:	6ae2                	ld	s5,24(sp)
    80002420:	6b42                	ld	s6,16(sp)
    80002422:	6ba2                	ld	s7,8(sp)
    80002424:	6c02                	ld	s8,0(sp)
    80002426:	6161                	addi	sp,sp,80
    80002428:	8082                	ret
    sleep(p, &p->lock);  //DOC: wait-sleep
    8000242a:	85e2                	mv	a1,s8
    8000242c:	854a                	mv	a0,s2
    8000242e:	00000097          	auipc	ra,0x0
    80002432:	e84080e7          	jalr	-380(ra) # 800022b2 <sleep>
    havekids = 0;
    80002436:	bf1d                	j	8000236c <wait+0x3c>

0000000080002438 <wakeup>:
{
    80002438:	7139                	addi	sp,sp,-64
    8000243a:	fc06                	sd	ra,56(sp)
    8000243c:	f822                	sd	s0,48(sp)
    8000243e:	f426                	sd	s1,40(sp)
    80002440:	f04a                	sd	s2,32(sp)
    80002442:	ec4e                	sd	s3,24(sp)
    80002444:	e852                	sd	s4,16(sp)
    80002446:	e456                	sd	s5,8(sp)
    80002448:	0080                	addi	s0,sp,64
    8000244a:	8a2a                	mv	s4,a0
  for(p = proc; p < &proc[NPROC]; p++) {
    8000244c:	00010497          	auipc	s1,0x10
    80002450:	91c48493          	addi	s1,s1,-1764 # 80011d68 <proc>
    if(p->state == SLEEPING && p->chan == chan) {
    80002454:	4985                	li	s3,1
      p->state = RUNNABLE;
    80002456:	4a89                	li	s5,2
  for(p = proc; p < &proc[NPROC]; p++) {
    80002458:	00015917          	auipc	s2,0x15
    8000245c:	31090913          	addi	s2,s2,784 # 80017768 <tickslock>
    80002460:	a821                	j	80002478 <wakeup+0x40>
      p->state = RUNNABLE;
    80002462:	0154ac23          	sw	s5,24(s1)
    release(&p->lock);
    80002466:	8526                	mv	a0,s1
    80002468:	fffff097          	auipc	ra,0xfffff
    8000246c:	8ae080e7          	jalr	-1874(ra) # 80000d16 <release>
  for(p = proc; p < &proc[NPROC]; p++) {
    80002470:	16848493          	addi	s1,s1,360
    80002474:	01248e63          	beq	s1,s2,80002490 <wakeup+0x58>
    acquire(&p->lock);
    80002478:	8526                	mv	a0,s1
    8000247a:	ffffe097          	auipc	ra,0xffffe
    8000247e:	7e8080e7          	jalr	2024(ra) # 80000c62 <acquire>
    if(p->state == SLEEPING && p->chan == chan) {
    80002482:	4c9c                	lw	a5,24(s1)
    80002484:	ff3791e3          	bne	a5,s3,80002466 <wakeup+0x2e>
    80002488:	749c                	ld	a5,40(s1)
    8000248a:	fd479ee3          	bne	a5,s4,80002466 <wakeup+0x2e>
    8000248e:	bfd1                	j	80002462 <wakeup+0x2a>
}
    80002490:	70e2                	ld	ra,56(sp)
    80002492:	7442                	ld	s0,48(sp)
    80002494:	74a2                	ld	s1,40(sp)
    80002496:	7902                	ld	s2,32(sp)
    80002498:	69e2                	ld	s3,24(sp)
    8000249a:	6a42                	ld	s4,16(sp)
    8000249c:	6aa2                	ld	s5,8(sp)
    8000249e:	6121                	addi	sp,sp,64
    800024a0:	8082                	ret

00000000800024a2 <kill>:
// Kill the process with the given pid.
// The victim won't exit until it tries to return
// to user space (see usertrap() in trap.c).
int
kill(int pid)
{
    800024a2:	7179                	addi	sp,sp,-48
    800024a4:	f406                	sd	ra,40(sp)
    800024a6:	f022                	sd	s0,32(sp)
    800024a8:	ec26                	sd	s1,24(sp)
    800024aa:	e84a                	sd	s2,16(sp)
    800024ac:	e44e                	sd	s3,8(sp)
    800024ae:	1800                	addi	s0,sp,48
    800024b0:	892a                	mv	s2,a0
  struct proc *p;

  for(p = proc; p < &proc[NPROC]; p++){
    800024b2:	00010497          	auipc	s1,0x10
    800024b6:	8b648493          	addi	s1,s1,-1866 # 80011d68 <proc>
    800024ba:	00015997          	auipc	s3,0x15
    800024be:	2ae98993          	addi	s3,s3,686 # 80017768 <tickslock>
    acquire(&p->lock);
    800024c2:	8526                	mv	a0,s1
    800024c4:	ffffe097          	auipc	ra,0xffffe
    800024c8:	79e080e7          	jalr	1950(ra) # 80000c62 <acquire>
    if(p->pid == pid){
    800024cc:	5c9c                	lw	a5,56(s1)
    800024ce:	01278d63          	beq	a5,s2,800024e8 <kill+0x46>
        p->state = RUNNABLE;
      }
      release(&p->lock);
      return 0;
    }
    release(&p->lock);
    800024d2:	8526                	mv	a0,s1
    800024d4:	fffff097          	auipc	ra,0xfffff
    800024d8:	842080e7          	jalr	-1982(ra) # 80000d16 <release>
  for(p = proc; p < &proc[NPROC]; p++){
    800024dc:	16848493          	addi	s1,s1,360
    800024e0:	ff3491e3          	bne	s1,s3,800024c2 <kill+0x20>
  }
  return -1;
    800024e4:	557d                	li	a0,-1
    800024e6:	a829                	j	80002500 <kill+0x5e>
      p->killed = 1;
    800024e8:	4785                	li	a5,1
    800024ea:	d89c                	sw	a5,48(s1)
      if(p->state == SLEEPING){
    800024ec:	4c98                	lw	a4,24(s1)
    800024ee:	4785                	li	a5,1
    800024f0:	00f70f63          	beq	a4,a5,8000250e <kill+0x6c>
      release(&p->lock);
    800024f4:	8526                	mv	a0,s1
    800024f6:	fffff097          	auipc	ra,0xfffff
    800024fa:	820080e7          	jalr	-2016(ra) # 80000d16 <release>
      return 0;
    800024fe:	4501                	li	a0,0
}
    80002500:	70a2                	ld	ra,40(sp)
    80002502:	7402                	ld	s0,32(sp)
    80002504:	64e2                	ld	s1,24(sp)
    80002506:	6942                	ld	s2,16(sp)
    80002508:	69a2                	ld	s3,8(sp)
    8000250a:	6145                	addi	sp,sp,48
    8000250c:	8082                	ret
        p->state = RUNNABLE;
    8000250e:	4789                	li	a5,2
    80002510:	cc9c                	sw	a5,24(s1)
    80002512:	b7cd                	j	800024f4 <kill+0x52>

0000000080002514 <either_copyout>:
// Copy to either a user address, or kernel address,
// depending on usr_dst.
// Returns 0 on success, -1 on error.
int
either_copyout(int user_dst, uint64 dst, void *src, uint64 len)
{
    80002514:	7179                	addi	sp,sp,-48
    80002516:	f406                	sd	ra,40(sp)
    80002518:	f022                	sd	s0,32(sp)
    8000251a:	ec26                	sd	s1,24(sp)
    8000251c:	e84a                	sd	s2,16(sp)
    8000251e:	e44e                	sd	s3,8(sp)
    80002520:	e052                	sd	s4,0(sp)
    80002522:	1800                	addi	s0,sp,48
    80002524:	84aa                	mv	s1,a0
    80002526:	892e                	mv	s2,a1
    80002528:	89b2                	mv	s3,a2
    8000252a:	8a36                	mv	s4,a3
  struct proc *p = myproc();
    8000252c:	fffff097          	auipc	ra,0xfffff
    80002530:	56c080e7          	jalr	1388(ra) # 80001a98 <myproc>
  if(user_dst){
    80002534:	c08d                	beqz	s1,80002556 <either_copyout+0x42>
    return copyout(p->pagetable, dst, src, len);
    80002536:	86d2                	mv	a3,s4
    80002538:	864e                	mv	a2,s3
    8000253a:	85ca                	mv	a1,s2
    8000253c:	6928                	ld	a0,80(a0)
    8000253e:	fffff097          	auipc	ra,0xfffff
    80002542:	236080e7          	jalr	566(ra) # 80001774 <copyout>
  } else {
    memmove((char *)dst, src, len);
    return 0;
  }
}
    80002546:	70a2                	ld	ra,40(sp)
    80002548:	7402                	ld	s0,32(sp)
    8000254a:	64e2                	ld	s1,24(sp)
    8000254c:	6942                	ld	s2,16(sp)
    8000254e:	69a2                	ld	s3,8(sp)
    80002550:	6a02                	ld	s4,0(sp)
    80002552:	6145                	addi	sp,sp,48
    80002554:	8082                	ret
    memmove((char *)dst, src, len);
    80002556:	000a061b          	sext.w	a2,s4
    8000255a:	85ce                	mv	a1,s3
    8000255c:	854a                	mv	a0,s2
    8000255e:	fffff097          	auipc	ra,0xfffff
    80002562:	86c080e7          	jalr	-1940(ra) # 80000dca <memmove>
    return 0;
    80002566:	8526                	mv	a0,s1
    80002568:	bff9                	j	80002546 <either_copyout+0x32>

000000008000256a <either_copyin>:
// Copy from either a user address, or kernel address,
// depending on usr_src.
// Returns 0 on success, -1 on error.
int
either_copyin(void *dst, int user_src, uint64 src, uint64 len)
{
    8000256a:	7179                	addi	sp,sp,-48
    8000256c:	f406                	sd	ra,40(sp)
    8000256e:	f022                	sd	s0,32(sp)
    80002570:	ec26                	sd	s1,24(sp)
    80002572:	e84a                	sd	s2,16(sp)
    80002574:	e44e                	sd	s3,8(sp)
    80002576:	e052                	sd	s4,0(sp)
    80002578:	1800                	addi	s0,sp,48
    8000257a:	892a                	mv	s2,a0
    8000257c:	84ae                	mv	s1,a1
    8000257e:	89b2                	mv	s3,a2
    80002580:	8a36                	mv	s4,a3
  struct proc *p = myproc();
    80002582:	fffff097          	auipc	ra,0xfffff
    80002586:	516080e7          	jalr	1302(ra) # 80001a98 <myproc>
  if(user_src){
    8000258a:	c08d                	beqz	s1,800025ac <either_copyin+0x42>
    return copyin(p->pagetable, dst, src, len);
    8000258c:	86d2                	mv	a3,s4
    8000258e:	864e                	mv	a2,s3
    80002590:	85ca                	mv	a1,s2
    80002592:	6928                	ld	a0,80(a0)
    80002594:	fffff097          	auipc	ra,0xfffff
    80002598:	26c080e7          	jalr	620(ra) # 80001800 <copyin>
  } else {
    memmove(dst, (char*)src, len);
    return 0;
  }
}
    8000259c:	70a2                	ld	ra,40(sp)
    8000259e:	7402                	ld	s0,32(sp)
    800025a0:	64e2                	ld	s1,24(sp)
    800025a2:	6942                	ld	s2,16(sp)
    800025a4:	69a2                	ld	s3,8(sp)
    800025a6:	6a02                	ld	s4,0(sp)
    800025a8:	6145                	addi	sp,sp,48
    800025aa:	8082                	ret
    memmove(dst, (char*)src, len);
    800025ac:	000a061b          	sext.w	a2,s4
    800025b0:	85ce                	mv	a1,s3
    800025b2:	854a                	mv	a0,s2
    800025b4:	fffff097          	auipc	ra,0xfffff
    800025b8:	816080e7          	jalr	-2026(ra) # 80000dca <memmove>
    return 0;
    800025bc:	8526                	mv	a0,s1
    800025be:	bff9                	j	8000259c <either_copyin+0x32>

00000000800025c0 <procdump>:
// Print a process listing to console.  For debugging.
// Runs when user types ^P on console.
// No lock to avoid wedging a stuck machine further.
void
procdump(void)
{
    800025c0:	715d                	addi	sp,sp,-80
    800025c2:	e486                	sd	ra,72(sp)
    800025c4:	e0a2                	sd	s0,64(sp)
    800025c6:	fc26                	sd	s1,56(sp)
    800025c8:	f84a                	sd	s2,48(sp)
    800025ca:	f44e                	sd	s3,40(sp)
    800025cc:	f052                	sd	s4,32(sp)
    800025ce:	ec56                	sd	s5,24(sp)
    800025d0:	e85a                	sd	s6,16(sp)
    800025d2:	e45e                	sd	s7,8(sp)
    800025d4:	0880                	addi	s0,sp,80
  [ZOMBIE]    "zombie"
  };
  struct proc *p;
  char *state;

  printf("\n");
    800025d6:	00006517          	auipc	a0,0x6
    800025da:	af250513          	addi	a0,a0,-1294 # 800080c8 <digits+0xb0>
    800025de:	ffffe097          	auipc	ra,0xffffe
    800025e2:	fe0080e7          	jalr	-32(ra) # 800005be <printf>
  for(p = proc; p < &proc[NPROC]; p++){
    800025e6:	00010497          	auipc	s1,0x10
    800025ea:	8da48493          	addi	s1,s1,-1830 # 80011ec0 <proc+0x158>
    800025ee:	00015917          	auipc	s2,0x15
    800025f2:	2d290913          	addi	s2,s2,722 # 800178c0 <bcache+0x140>
    if(p->state == UNUSED)
      continue;
    if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
    800025f6:	4b11                	li	s6,4
      state = states[p->state];
    else
      state = "???";
    800025f8:	00006997          	auipc	s3,0x6
    800025fc:	c3098993          	addi	s3,s3,-976 # 80008228 <states.1722+0xc8>
    printf("%d %s %s", p->pid, state, p->name);
    80002600:	00006a97          	auipc	s5,0x6
    80002604:	c30a8a93          	addi	s5,s5,-976 # 80008230 <states.1722+0xd0>
    printf("\n");
    80002608:	00006a17          	auipc	s4,0x6
    8000260c:	ac0a0a13          	addi	s4,s4,-1344 # 800080c8 <digits+0xb0>
    if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
    80002610:	00006b97          	auipc	s7,0x6
    80002614:	b50b8b93          	addi	s7,s7,-1200 # 80008160 <states.1722>
    80002618:	a015                	j	8000263c <procdump+0x7c>
    printf("%d %s %s", p->pid, state, p->name);
    8000261a:	86ba                	mv	a3,a4
    8000261c:	ee072583          	lw	a1,-288(a4)
    80002620:	8556                	mv	a0,s5
    80002622:	ffffe097          	auipc	ra,0xffffe
    80002626:	f9c080e7          	jalr	-100(ra) # 800005be <printf>
    printf("\n");
    8000262a:	8552                	mv	a0,s4
    8000262c:	ffffe097          	auipc	ra,0xffffe
    80002630:	f92080e7          	jalr	-110(ra) # 800005be <printf>
  for(p = proc; p < &proc[NPROC]; p++){
    80002634:	16848493          	addi	s1,s1,360
    80002638:	03248163          	beq	s1,s2,8000265a <procdump+0x9a>
    if(p->state == UNUSED)
    8000263c:	8726                	mv	a4,s1
    8000263e:	ec04a783          	lw	a5,-320(s1)
    80002642:	dbed                	beqz	a5,80002634 <procdump+0x74>
      state = "???";
    80002644:	864e                	mv	a2,s3
    if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
    80002646:	fcfb6ae3          	bltu	s6,a5,8000261a <procdump+0x5a>
    8000264a:	1782                	slli	a5,a5,0x20
    8000264c:	9381                	srli	a5,a5,0x20
    8000264e:	078e                	slli	a5,a5,0x3
    80002650:	97de                	add	a5,a5,s7
    80002652:	6390                	ld	a2,0(a5)
    80002654:	f279                	bnez	a2,8000261a <procdump+0x5a>
      state = "???";
    80002656:	864e                	mv	a2,s3
    80002658:	b7c9                	j	8000261a <procdump+0x5a>
  }
}
    8000265a:	60a6                	ld	ra,72(sp)
    8000265c:	6406                	ld	s0,64(sp)
    8000265e:	74e2                	ld	s1,56(sp)
    80002660:	7942                	ld	s2,48(sp)
    80002662:	79a2                	ld	s3,40(sp)
    80002664:	7a02                	ld	s4,32(sp)
    80002666:	6ae2                	ld	s5,24(sp)
    80002668:	6b42                	ld	s6,16(sp)
    8000266a:	6ba2                	ld	s7,8(sp)
    8000266c:	6161                	addi	sp,sp,80
    8000266e:	8082                	ret

0000000080002670 <swtch>:
    80002670:	00153023          	sd	ra,0(a0)
    80002674:	00253423          	sd	sp,8(a0)
    80002678:	e900                	sd	s0,16(a0)
    8000267a:	ed04                	sd	s1,24(a0)
    8000267c:	03253023          	sd	s2,32(a0)
    80002680:	03353423          	sd	s3,40(a0)
    80002684:	03453823          	sd	s4,48(a0)
    80002688:	03553c23          	sd	s5,56(a0)
    8000268c:	05653023          	sd	s6,64(a0)
    80002690:	05753423          	sd	s7,72(a0)
    80002694:	05853823          	sd	s8,80(a0)
    80002698:	05953c23          	sd	s9,88(a0)
    8000269c:	07a53023          	sd	s10,96(a0)
    800026a0:	07b53423          	sd	s11,104(a0)
    800026a4:	0005b083          	ld	ra,0(a1)
    800026a8:	0085b103          	ld	sp,8(a1)
    800026ac:	6980                	ld	s0,16(a1)
    800026ae:	6d84                	ld	s1,24(a1)
    800026b0:	0205b903          	ld	s2,32(a1)
    800026b4:	0285b983          	ld	s3,40(a1)
    800026b8:	0305ba03          	ld	s4,48(a1)
    800026bc:	0385ba83          	ld	s5,56(a1)
    800026c0:	0405bb03          	ld	s6,64(a1)
    800026c4:	0485bb83          	ld	s7,72(a1)
    800026c8:	0505bc03          	ld	s8,80(a1)
    800026cc:	0585bc83          	ld	s9,88(a1)
    800026d0:	0605bd03          	ld	s10,96(a1)
    800026d4:	0685bd83          	ld	s11,104(a1)
    800026d8:	8082                	ret

00000000800026da <trapinit>:

extern int devintr();

void
trapinit(void)
{
    800026da:	1141                	addi	sp,sp,-16
    800026dc:	e406                	sd	ra,8(sp)
    800026de:	e022                	sd	s0,0(sp)
    800026e0:	0800                	addi	s0,sp,16
  initlock(&tickslock, "time");
    800026e2:	00006597          	auipc	a1,0x6
    800026e6:	b8658593          	addi	a1,a1,-1146 # 80008268 <states.1722+0x108>
    800026ea:	00015517          	auipc	a0,0x15
    800026ee:	07e50513          	addi	a0,a0,126 # 80017768 <tickslock>
    800026f2:	ffffe097          	auipc	ra,0xffffe
    800026f6:	4e0080e7          	jalr	1248(ra) # 80000bd2 <initlock>
}
    800026fa:	60a2                	ld	ra,8(sp)
    800026fc:	6402                	ld	s0,0(sp)
    800026fe:	0141                	addi	sp,sp,16
    80002700:	8082                	ret

0000000080002702 <trapinithart>:

// set up to take exceptions and traps while in the kernel.
void
trapinithart(void)
{
    80002702:	1141                	addi	sp,sp,-16
    80002704:	e422                	sd	s0,8(sp)
    80002706:	0800                	addi	s0,sp,16
  asm volatile("csrw stvec, %0" : : "r" (x));
    80002708:	00003797          	auipc	a5,0x3
    8000270c:	64878793          	addi	a5,a5,1608 # 80005d50 <kernelvec>
    80002710:	10579073          	csrw	stvec,a5
  w_stvec((uint64)kernelvec);
}
    80002714:	6422                	ld	s0,8(sp)
    80002716:	0141                	addi	sp,sp,16
    80002718:	8082                	ret

000000008000271a <usertrapret>:
//
// return to user space
//
void
usertrapret(void)
{
    8000271a:	1141                	addi	sp,sp,-16
    8000271c:	e406                	sd	ra,8(sp)
    8000271e:	e022                	sd	s0,0(sp)
    80002720:	0800                	addi	s0,sp,16
  struct proc *p = myproc();
    80002722:	fffff097          	auipc	ra,0xfffff
    80002726:	376080e7          	jalr	886(ra) # 80001a98 <myproc>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    8000272a:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() & ~SSTATUS_SIE);
    8000272e:	9bf5                	andi	a5,a5,-3
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80002730:	10079073          	csrw	sstatus,a5
  // kerneltrap() to usertrap(), so turn off interrupts until
  // we're back in user space, where usertrap() is correct.
  intr_off();

  // send syscalls, interrupts, and exceptions to trampoline.S
  w_stvec(TRAMPOLINE + (uservec - trampoline));
    80002734:	00005617          	auipc	a2,0x5
    80002738:	8cc60613          	addi	a2,a2,-1844 # 80007000 <_trampoline>
    8000273c:	00005697          	auipc	a3,0x5
    80002740:	8c468693          	addi	a3,a3,-1852 # 80007000 <_trampoline>
    80002744:	8e91                	sub	a3,a3,a2
    80002746:	040007b7          	lui	a5,0x4000
    8000274a:	17fd                	addi	a5,a5,-1
    8000274c:	07b2                	slli	a5,a5,0xc
    8000274e:	96be                	add	a3,a3,a5
  asm volatile("csrw stvec, %0" : : "r" (x));
    80002750:	10569073          	csrw	stvec,a3

  // set up trapframe values that uservec will need when
  // the process next re-enters the kernel.
  p->trapframe->kernel_satp = r_satp();         // kernel page table
    80002754:	6d38                	ld	a4,88(a0)
  asm volatile("csrr %0, satp" : "=r" (x) );
    80002756:	180026f3          	csrr	a3,satp
    8000275a:	e314                	sd	a3,0(a4)
  p->trapframe->kernel_sp = p->kstack + PGSIZE; // process's kernel stack
    8000275c:	6d38                	ld	a4,88(a0)
    8000275e:	6134                	ld	a3,64(a0)
    80002760:	6585                	lui	a1,0x1
    80002762:	96ae                	add	a3,a3,a1
    80002764:	e714                	sd	a3,8(a4)
  p->trapframe->kernel_trap = (uint64)usertrap;
    80002766:	6d38                	ld	a4,88(a0)
    80002768:	00000697          	auipc	a3,0x0
    8000276c:	13868693          	addi	a3,a3,312 # 800028a0 <usertrap>
    80002770:	eb14                	sd	a3,16(a4)
  p->trapframe->kernel_hartid = r_tp();         // hartid for cpuid()
    80002772:	6d38                	ld	a4,88(a0)
  asm volatile("mv %0, tp" : "=r" (x) );
    80002774:	8692                	mv	a3,tp
    80002776:	f314                	sd	a3,32(a4)
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80002778:	100026f3          	csrr	a3,sstatus
  // set up the registers that trampoline.S's sret will use
  // to get to user space.
  
  // set S Previous Privilege mode to User.
  unsigned long x = r_sstatus();
  x &= ~SSTATUS_SPP; // clear SPP to 0 for user mode
    8000277c:	eff6f693          	andi	a3,a3,-257
  x |= SSTATUS_SPIE; // enable interrupts in user mode
    80002780:	0206e693          	ori	a3,a3,32
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80002784:	10069073          	csrw	sstatus,a3
  w_sstatus(x);

  // set S Exception Program Counter to the saved user pc.
  w_sepc(p->trapframe->epc);
    80002788:	6d38                	ld	a4,88(a0)
  asm volatile("csrw sepc, %0" : : "r" (x));
    8000278a:	6f18                	ld	a4,24(a4)
    8000278c:	14171073          	csrw	sepc,a4

  // tell trampoline.S the user page table to switch to.
  uint64 satp = MAKE_SATP(p->pagetable);
    80002790:	692c                	ld	a1,80(a0)
    80002792:	81b1                	srli	a1,a1,0xc

  // jump to trampoline.S at the top of memory, which 
  // switches to the user page table, restores user registers,
  // and switches to user mode with sret.
  uint64 fn = TRAMPOLINE + (userret - trampoline);
    80002794:	00005717          	auipc	a4,0x5
    80002798:	8fc70713          	addi	a4,a4,-1796 # 80007090 <userret>
    8000279c:	8f11                	sub	a4,a4,a2
    8000279e:	97ba                	add	a5,a5,a4
  ((void (*)(uint64,uint64))fn)(TRAPFRAME, satp);
    800027a0:	577d                	li	a4,-1
    800027a2:	177e                	slli	a4,a4,0x3f
    800027a4:	8dd9                	or	a1,a1,a4
    800027a6:	02000537          	lui	a0,0x2000
    800027aa:	157d                	addi	a0,a0,-1
    800027ac:	0536                	slli	a0,a0,0xd
    800027ae:	9782                	jalr	a5
}
    800027b0:	60a2                	ld	ra,8(sp)
    800027b2:	6402                	ld	s0,0(sp)
    800027b4:	0141                	addi	sp,sp,16
    800027b6:	8082                	ret

00000000800027b8 <clockintr>:
  w_sstatus(sstatus);
}

void
clockintr()
{
    800027b8:	1101                	addi	sp,sp,-32
    800027ba:	ec06                	sd	ra,24(sp)
    800027bc:	e822                	sd	s0,16(sp)
    800027be:	e426                	sd	s1,8(sp)
    800027c0:	1000                	addi	s0,sp,32
  acquire(&tickslock);
    800027c2:	00015497          	auipc	s1,0x15
    800027c6:	fa648493          	addi	s1,s1,-90 # 80017768 <tickslock>
    800027ca:	8526                	mv	a0,s1
    800027cc:	ffffe097          	auipc	ra,0xffffe
    800027d0:	496080e7          	jalr	1174(ra) # 80000c62 <acquire>
  ticks++;
    800027d4:	00007517          	auipc	a0,0x7
    800027d8:	84c50513          	addi	a0,a0,-1972 # 80009020 <ticks>
    800027dc:	411c                	lw	a5,0(a0)
    800027de:	2785                	addiw	a5,a5,1
    800027e0:	c11c                	sw	a5,0(a0)
  wakeup(&ticks);
    800027e2:	00000097          	auipc	ra,0x0
    800027e6:	c56080e7          	jalr	-938(ra) # 80002438 <wakeup>
  release(&tickslock);
    800027ea:	8526                	mv	a0,s1
    800027ec:	ffffe097          	auipc	ra,0xffffe
    800027f0:	52a080e7          	jalr	1322(ra) # 80000d16 <release>
}
    800027f4:	60e2                	ld	ra,24(sp)
    800027f6:	6442                	ld	s0,16(sp)
    800027f8:	64a2                	ld	s1,8(sp)
    800027fa:	6105                	addi	sp,sp,32
    800027fc:	8082                	ret

00000000800027fe <devintr>:
// returns 2 if timer interrupt,
// 1 if other device,
// 0 if not recognized.
int
devintr()
{
    800027fe:	1101                	addi	sp,sp,-32
    80002800:	ec06                	sd	ra,24(sp)
    80002802:	e822                	sd	s0,16(sp)
    80002804:	e426                	sd	s1,8(sp)
    80002806:	1000                	addi	s0,sp,32
  asm volatile("csrr %0, scause" : "=r" (x) );
    80002808:	14202773          	csrr	a4,scause
  uint64 scause = r_scause();

  if((scause & 0x8000000000000000L) &&
    8000280c:	00074d63          	bltz	a4,80002826 <devintr+0x28>
    // now allowed to interrupt again.
    if(irq)
      plic_complete(irq);

    return 1;
  } else if(scause == 0x8000000000000001L){
    80002810:	57fd                	li	a5,-1
    80002812:	17fe                	slli	a5,a5,0x3f
    80002814:	0785                	addi	a5,a5,1
    // the SSIP bit in sip.
    w_sip(r_sip() & ~2);

    return 2;
  } else {
    return 0;
    80002816:	4501                	li	a0,0
  } else if(scause == 0x8000000000000001L){
    80002818:	06f70363          	beq	a4,a5,8000287e <devintr+0x80>
  }
}
    8000281c:	60e2                	ld	ra,24(sp)
    8000281e:	6442                	ld	s0,16(sp)
    80002820:	64a2                	ld	s1,8(sp)
    80002822:	6105                	addi	sp,sp,32
    80002824:	8082                	ret
     (scause & 0xff) == 9){
    80002826:	0ff77793          	andi	a5,a4,255
  if((scause & 0x8000000000000000L) &&
    8000282a:	46a5                	li	a3,9
    8000282c:	fed792e3          	bne	a5,a3,80002810 <devintr+0x12>
    int irq = plic_claim();
    80002830:	00003097          	auipc	ra,0x3
    80002834:	628080e7          	jalr	1576(ra) # 80005e58 <plic_claim>
    80002838:	84aa                	mv	s1,a0
    if(irq == UART0_IRQ){
    8000283a:	47a9                	li	a5,10
    8000283c:	02f50763          	beq	a0,a5,8000286a <devintr+0x6c>
    } else if(irq == VIRTIO0_IRQ){
    80002840:	4785                	li	a5,1
    80002842:	02f50963          	beq	a0,a5,80002874 <devintr+0x76>
    return 1;
    80002846:	4505                	li	a0,1
    } else if(irq){
    80002848:	d8f1                	beqz	s1,8000281c <devintr+0x1e>
      printf("unexpected interrupt irq=%d\n", irq);
    8000284a:	85a6                	mv	a1,s1
    8000284c:	00006517          	auipc	a0,0x6
    80002850:	a2450513          	addi	a0,a0,-1500 # 80008270 <states.1722+0x110>
    80002854:	ffffe097          	auipc	ra,0xffffe
    80002858:	d6a080e7          	jalr	-662(ra) # 800005be <printf>
      plic_complete(irq);
    8000285c:	8526                	mv	a0,s1
    8000285e:	00003097          	auipc	ra,0x3
    80002862:	61e080e7          	jalr	1566(ra) # 80005e7c <plic_complete>
    return 1;
    80002866:	4505                	li	a0,1
    80002868:	bf55                	j	8000281c <devintr+0x1e>
      uartintr();
    8000286a:	ffffe097          	auipc	ra,0xffffe
    8000286e:	1b8080e7          	jalr	440(ra) # 80000a22 <uartintr>
    80002872:	b7ed                	j	8000285c <devintr+0x5e>
      virtio_disk_intr();
    80002874:	00004097          	auipc	ra,0x4
    80002878:	ab4080e7          	jalr	-1356(ra) # 80006328 <virtio_disk_intr>
    8000287c:	b7c5                	j	8000285c <devintr+0x5e>
    if(cpuid() == 0){
    8000287e:	fffff097          	auipc	ra,0xfffff
    80002882:	1ee080e7          	jalr	494(ra) # 80001a6c <cpuid>
    80002886:	c901                	beqz	a0,80002896 <devintr+0x98>
  asm volatile("csrr %0, sip" : "=r" (x) );
    80002888:	144027f3          	csrr	a5,sip
    w_sip(r_sip() & ~2);
    8000288c:	9bf5                	andi	a5,a5,-3
  asm volatile("csrw sip, %0" : : "r" (x));
    8000288e:	14479073          	csrw	sip,a5
    return 2;
    80002892:	4509                	li	a0,2
    80002894:	b761                	j	8000281c <devintr+0x1e>
      clockintr();
    80002896:	00000097          	auipc	ra,0x0
    8000289a:	f22080e7          	jalr	-222(ra) # 800027b8 <clockintr>
    8000289e:	b7ed                	j	80002888 <devintr+0x8a>

00000000800028a0 <usertrap>:
{
    800028a0:	7179                	addi	sp,sp,-48
    800028a2:	f406                	sd	ra,40(sp)
    800028a4:	f022                	sd	s0,32(sp)
    800028a6:	ec26                	sd	s1,24(sp)
    800028a8:	e84a                	sd	s2,16(sp)
    800028aa:	e44e                	sd	s3,8(sp)
    800028ac:	e052                	sd	s4,0(sp)
    800028ae:	1800                	addi	s0,sp,48
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    800028b0:	100027f3          	csrr	a5,sstatus
  if((r_sstatus() & SSTATUS_SPP) != 0)
    800028b4:	1007f793          	andi	a5,a5,256
    800028b8:	e7a5                	bnez	a5,80002920 <usertrap+0x80>
  asm volatile("csrw stvec, %0" : : "r" (x));
    800028ba:	00003797          	auipc	a5,0x3
    800028be:	49678793          	addi	a5,a5,1174 # 80005d50 <kernelvec>
    800028c2:	10579073          	csrw	stvec,a5
  struct proc *p = myproc();
    800028c6:	fffff097          	auipc	ra,0xfffff
    800028ca:	1d2080e7          	jalr	466(ra) # 80001a98 <myproc>
    800028ce:	84aa                	mv	s1,a0
  p->trapframe->epc = r_sepc();
    800028d0:	6d3c                	ld	a5,88(a0)
  asm volatile("csrr %0, sepc" : "=r" (x) );
    800028d2:	14102773          	csrr	a4,sepc
    800028d6:	ef98                	sd	a4,24(a5)
  asm volatile("csrr %0, scause" : "=r" (x) );
    800028d8:	14202773          	csrr	a4,scause
  if(r_scause() == 8){
    800028dc:	47a1                	li	a5,8
    800028de:	04f71f63          	bne	a4,a5,8000293c <usertrap+0x9c>
    if(p->killed)
    800028e2:	591c                	lw	a5,48(a0)
    800028e4:	e7b1                	bnez	a5,80002930 <usertrap+0x90>
    p->trapframe->epc += 4;
    800028e6:	6cb8                	ld	a4,88(s1)
    800028e8:	6f1c                	ld	a5,24(a4)
    800028ea:	0791                	addi	a5,a5,4
    800028ec:	ef1c                	sd	a5,24(a4)
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    800028ee:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() | SSTATUS_SIE);
    800028f2:	0027e793          	ori	a5,a5,2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    800028f6:	10079073          	csrw	sstatus,a5
    syscall();
    800028fa:	00000097          	auipc	ra,0x0
    800028fe:	374080e7          	jalr	884(ra) # 80002c6e <syscall>
  if(p->killed)
    80002902:	589c                	lw	a5,48(s1)
    80002904:	10079363          	bnez	a5,80002a0a <usertrap+0x16a>
  usertrapret();
    80002908:	00000097          	auipc	ra,0x0
    8000290c:	e12080e7          	jalr	-494(ra) # 8000271a <usertrapret>
}
    80002910:	70a2                	ld	ra,40(sp)
    80002912:	7402                	ld	s0,32(sp)
    80002914:	64e2                	ld	s1,24(sp)
    80002916:	6942                	ld	s2,16(sp)
    80002918:	69a2                	ld	s3,8(sp)
    8000291a:	6a02                	ld	s4,0(sp)
    8000291c:	6145                	addi	sp,sp,48
    8000291e:	8082                	ret
    panic("usertrap: not from user mode");
    80002920:	00006517          	auipc	a0,0x6
    80002924:	97050513          	addi	a0,a0,-1680 # 80008290 <states.1722+0x130>
    80002928:	ffffe097          	auipc	ra,0xffffe
    8000292c:	c4c080e7          	jalr	-948(ra) # 80000574 <panic>
      exit(-1);
    80002930:	557d                	li	a0,-1
    80002932:	00000097          	auipc	ra,0x0
    80002936:	838080e7          	jalr	-1992(ra) # 8000216a <exit>
    8000293a:	b775                	j	800028e6 <usertrap+0x46>
  } else if((which_dev = devintr()) != 0){
    8000293c:	00000097          	auipc	ra,0x0
    80002940:	ec2080e7          	jalr	-318(ra) # 800027fe <devintr>
    80002944:	892a                	mv	s2,a0
    80002946:	ed5d                	bnez	a0,80002a04 <usertrap+0x164>
  asm volatile("csrr %0, scause" : "=r" (x) );
    80002948:	14202773          	csrr	a4,scause
  } else if(r_scause() == 13 || r_scause() == 15){
    8000294c:	47b5                	li	a5,13
    8000294e:	00f70763          	beq	a4,a5,8000295c <usertrap+0xbc>
    80002952:	14202773          	csrr	a4,scause
    80002956:	47bd                	li	a5,15
    80002958:	06f71c63          	bne	a4,a5,800029d0 <usertrap+0x130>
    struct proc *p = myproc();
    8000295c:	fffff097          	auipc	ra,0xfffff
    80002960:	13c080e7          	jalr	316(ra) # 80001a98 <myproc>
    80002964:	892a                	mv	s2,a0
  asm volatile("csrr %0, stval" : "=r" (x) );
    80002966:	143029f3          	csrr	s3,stval
    if(va >= p->sz || va <= PGROUNDDOWN(p->trapframe->sp)) {
    8000296a:	653c                	ld	a5,72(a0)
    8000296c:	00f9f863          	bleu	a5,s3,8000297c <usertrap+0xdc>
    80002970:	6d3c                	ld	a5,88(a0)
    80002972:	7b98                	ld	a4,48(a5)
    80002974:	77fd                	lui	a5,0xfffff
    80002976:	8ff9                	and	a5,a5,a4
    80002978:	0137e663          	bltu	a5,s3,80002984 <usertrap+0xe4>
      p->killed = 1;
    8000297c:	4785                	li	a5,1
    8000297e:	02f92823          	sw	a5,48(s2)
      goto kill_;
    80002982:	b741                	j	80002902 <usertrap+0x62>
    char *mem = kalloc();
    80002984:	ffffe097          	auipc	ra,0xffffe
    80002988:	1ee080e7          	jalr	494(ra) # 80000b72 <kalloc>
    8000298c:	8a2a                	mv	s4,a0
    if(mem == 0){
    8000298e:	cd0d                	beqz	a0,800029c8 <usertrap+0x128>
    memset(mem, 0, PGSIZE);
    80002990:	6605                	lui	a2,0x1
    80002992:	4581                	li	a1,0
    80002994:	ffffe097          	auipc	ra,0xffffe
    80002998:	3ca080e7          	jalr	970(ra) # 80000d5e <memset>
    if(mappages(p->pagetable, va, PGSIZE, (uint64)mem, PTE_W|PTE_X|PTE_R|PTE_U) != 0){
    8000299c:	4779                	li	a4,30
    8000299e:	86d2                	mv	a3,s4
    800029a0:	6605                	lui	a2,0x1
    800029a2:	75fd                	lui	a1,0xfffff
    800029a4:	00b9f5b3          	and	a1,s3,a1
    800029a8:	05093503          	ld	a0,80(s2)
    800029ac:	ffffe097          	auipc	ra,0xffffe
    800029b0:	7ca080e7          	jalr	1994(ra) # 80001176 <mappages>
    800029b4:	d539                	beqz	a0,80002902 <usertrap+0x62>
      kfree(mem);
    800029b6:	8552                	mv	a0,s4
    800029b8:	ffffe097          	auipc	ra,0xffffe
    800029bc:	0ba080e7          	jalr	186(ra) # 80000a72 <kfree>
      p->killed = 1;
    800029c0:	4785                	li	a5,1
    800029c2:	02f92823          	sw	a5,48(s2)
      goto kill_;
    800029c6:	bf35                	j	80002902 <usertrap+0x62>
      p->killed = 1;
    800029c8:	4785                	li	a5,1
    800029ca:	02f92823          	sw	a5,48(s2)
      goto kill_;
    800029ce:	bf15                	j	80002902 <usertrap+0x62>
  asm volatile("csrr %0, scause" : "=r" (x) );
    800029d0:	142025f3          	csrr	a1,scause
    printf("usertrap(): unexpected scause %p pid=%d\n", r_scause(), p->pid);
    800029d4:	5c90                	lw	a2,56(s1)
    800029d6:	00006517          	auipc	a0,0x6
    800029da:	8da50513          	addi	a0,a0,-1830 # 800082b0 <states.1722+0x150>
    800029de:	ffffe097          	auipc	ra,0xffffe
    800029e2:	be0080e7          	jalr	-1056(ra) # 800005be <printf>
  asm volatile("csrr %0, sepc" : "=r" (x) );
    800029e6:	141025f3          	csrr	a1,sepc
  asm volatile("csrr %0, stval" : "=r" (x) );
    800029ea:	14302673          	csrr	a2,stval
    printf("            sepc=%p stval=%p\n", r_sepc(), r_stval());
    800029ee:	00006517          	auipc	a0,0x6
    800029f2:	8f250513          	addi	a0,a0,-1806 # 800082e0 <states.1722+0x180>
    800029f6:	ffffe097          	auipc	ra,0xffffe
    800029fa:	bc8080e7          	jalr	-1080(ra) # 800005be <printf>
    p->killed = 1;
    800029fe:	4785                	li	a5,1
    80002a00:	d89c                	sw	a5,48(s1)
  if(p->killed)
    80002a02:	a029                	j	80002a0c <usertrap+0x16c>
    80002a04:	589c                	lw	a5,48(s1)
    80002a06:	cb81                	beqz	a5,80002a16 <usertrap+0x176>
    80002a08:	a011                	j	80002a0c <usertrap+0x16c>
    80002a0a:	4901                	li	s2,0
    exit(-1);
    80002a0c:	557d                	li	a0,-1
    80002a0e:	fffff097          	auipc	ra,0xfffff
    80002a12:	75c080e7          	jalr	1884(ra) # 8000216a <exit>
  if(which_dev == 2)
    80002a16:	4789                	li	a5,2
    80002a18:	eef918e3          	bne	s2,a5,80002908 <usertrap+0x68>
    yield();
    80002a1c:	00000097          	auipc	ra,0x0
    80002a20:	85a080e7          	jalr	-1958(ra) # 80002276 <yield>
    80002a24:	b5d5                	j	80002908 <usertrap+0x68>

0000000080002a26 <kerneltrap>:
{
    80002a26:	7179                	addi	sp,sp,-48
    80002a28:	f406                	sd	ra,40(sp)
    80002a2a:	f022                	sd	s0,32(sp)
    80002a2c:	ec26                	sd	s1,24(sp)
    80002a2e:	e84a                	sd	s2,16(sp)
    80002a30:	e44e                	sd	s3,8(sp)
    80002a32:	1800                	addi	s0,sp,48
  asm volatile("csrr %0, sepc" : "=r" (x) );
    80002a34:	14102973          	csrr	s2,sepc
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80002a38:	100024f3          	csrr	s1,sstatus
  asm volatile("csrr %0, scause" : "=r" (x) );
    80002a3c:	142029f3          	csrr	s3,scause
  if((sstatus & SSTATUS_SPP) == 0)
    80002a40:	1004f793          	andi	a5,s1,256
    80002a44:	cb85                	beqz	a5,80002a74 <kerneltrap+0x4e>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80002a46:	100027f3          	csrr	a5,sstatus
  return (x & SSTATUS_SIE) != 0;
    80002a4a:	8b89                	andi	a5,a5,2
  if(intr_get() != 0)
    80002a4c:	ef85                	bnez	a5,80002a84 <kerneltrap+0x5e>
  if((which_dev = devintr()) == 0){
    80002a4e:	00000097          	auipc	ra,0x0
    80002a52:	db0080e7          	jalr	-592(ra) # 800027fe <devintr>
    80002a56:	cd1d                	beqz	a0,80002a94 <kerneltrap+0x6e>
  if(which_dev == 2 && myproc() != 0 && myproc()->state == RUNNING)
    80002a58:	4789                	li	a5,2
    80002a5a:	06f50a63          	beq	a0,a5,80002ace <kerneltrap+0xa8>
  asm volatile("csrw sepc, %0" : : "r" (x));
    80002a5e:	14191073          	csrw	sepc,s2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80002a62:	10049073          	csrw	sstatus,s1
}
    80002a66:	70a2                	ld	ra,40(sp)
    80002a68:	7402                	ld	s0,32(sp)
    80002a6a:	64e2                	ld	s1,24(sp)
    80002a6c:	6942                	ld	s2,16(sp)
    80002a6e:	69a2                	ld	s3,8(sp)
    80002a70:	6145                	addi	sp,sp,48
    80002a72:	8082                	ret
    panic("kerneltrap: not from supervisor mode");
    80002a74:	00006517          	auipc	a0,0x6
    80002a78:	88c50513          	addi	a0,a0,-1908 # 80008300 <states.1722+0x1a0>
    80002a7c:	ffffe097          	auipc	ra,0xffffe
    80002a80:	af8080e7          	jalr	-1288(ra) # 80000574 <panic>
    panic("kerneltrap: interrupts enabled");
    80002a84:	00006517          	auipc	a0,0x6
    80002a88:	8a450513          	addi	a0,a0,-1884 # 80008328 <states.1722+0x1c8>
    80002a8c:	ffffe097          	auipc	ra,0xffffe
    80002a90:	ae8080e7          	jalr	-1304(ra) # 80000574 <panic>
    printf("scause %p\n", scause);
    80002a94:	85ce                	mv	a1,s3
    80002a96:	00006517          	auipc	a0,0x6
    80002a9a:	8b250513          	addi	a0,a0,-1870 # 80008348 <states.1722+0x1e8>
    80002a9e:	ffffe097          	auipc	ra,0xffffe
    80002aa2:	b20080e7          	jalr	-1248(ra) # 800005be <printf>
  asm volatile("csrr %0, sepc" : "=r" (x) );
    80002aa6:	141025f3          	csrr	a1,sepc
  asm volatile("csrr %0, stval" : "=r" (x) );
    80002aaa:	14302673          	csrr	a2,stval
    printf("sepc=%p stval=%p\n", r_sepc(), r_stval());
    80002aae:	00006517          	auipc	a0,0x6
    80002ab2:	8aa50513          	addi	a0,a0,-1878 # 80008358 <states.1722+0x1f8>
    80002ab6:	ffffe097          	auipc	ra,0xffffe
    80002aba:	b08080e7          	jalr	-1272(ra) # 800005be <printf>
    panic("kerneltrap");
    80002abe:	00006517          	auipc	a0,0x6
    80002ac2:	8b250513          	addi	a0,a0,-1870 # 80008370 <states.1722+0x210>
    80002ac6:	ffffe097          	auipc	ra,0xffffe
    80002aca:	aae080e7          	jalr	-1362(ra) # 80000574 <panic>
  if(which_dev == 2 && myproc() != 0 && myproc()->state == RUNNING)
    80002ace:	fffff097          	auipc	ra,0xfffff
    80002ad2:	fca080e7          	jalr	-54(ra) # 80001a98 <myproc>
    80002ad6:	d541                	beqz	a0,80002a5e <kerneltrap+0x38>
    80002ad8:	fffff097          	auipc	ra,0xfffff
    80002adc:	fc0080e7          	jalr	-64(ra) # 80001a98 <myproc>
    80002ae0:	4d18                	lw	a4,24(a0)
    80002ae2:	478d                	li	a5,3
    80002ae4:	f6f71de3          	bne	a4,a5,80002a5e <kerneltrap+0x38>
    yield();
    80002ae8:	fffff097          	auipc	ra,0xfffff
    80002aec:	78e080e7          	jalr	1934(ra) # 80002276 <yield>
    80002af0:	b7bd                	j	80002a5e <kerneltrap+0x38>

0000000080002af2 <argraw>:
  return strlen(buf);
}

static uint64
argraw(int n)
{
    80002af2:	1101                	addi	sp,sp,-32
    80002af4:	ec06                	sd	ra,24(sp)
    80002af6:	e822                	sd	s0,16(sp)
    80002af8:	e426                	sd	s1,8(sp)
    80002afa:	1000                	addi	s0,sp,32
    80002afc:	84aa                	mv	s1,a0
  struct proc *p = myproc();
    80002afe:	fffff097          	auipc	ra,0xfffff
    80002b02:	f9a080e7          	jalr	-102(ra) # 80001a98 <myproc>
  switch (n) {
    80002b06:	4795                	li	a5,5
    80002b08:	0497e363          	bltu	a5,s1,80002b4e <argraw+0x5c>
    80002b0c:	1482                	slli	s1,s1,0x20
    80002b0e:	9081                	srli	s1,s1,0x20
    80002b10:	048a                	slli	s1,s1,0x2
    80002b12:	00006717          	auipc	a4,0x6
    80002b16:	86e70713          	addi	a4,a4,-1938 # 80008380 <states.1722+0x220>
    80002b1a:	94ba                	add	s1,s1,a4
    80002b1c:	409c                	lw	a5,0(s1)
    80002b1e:	97ba                	add	a5,a5,a4
    80002b20:	8782                	jr	a5
  case 0:
    return p->trapframe->a0;
    80002b22:	6d3c                	ld	a5,88(a0)
    80002b24:	7ba8                	ld	a0,112(a5)
  case 5:
    return p->trapframe->a5;
  }
  panic("argraw");
  return -1;
}
    80002b26:	60e2                	ld	ra,24(sp)
    80002b28:	6442                	ld	s0,16(sp)
    80002b2a:	64a2                	ld	s1,8(sp)
    80002b2c:	6105                	addi	sp,sp,32
    80002b2e:	8082                	ret
    return p->trapframe->a1;
    80002b30:	6d3c                	ld	a5,88(a0)
    80002b32:	7fa8                	ld	a0,120(a5)
    80002b34:	bfcd                	j	80002b26 <argraw+0x34>
    return p->trapframe->a2;
    80002b36:	6d3c                	ld	a5,88(a0)
    80002b38:	63c8                	ld	a0,128(a5)
    80002b3a:	b7f5                	j	80002b26 <argraw+0x34>
    return p->trapframe->a3;
    80002b3c:	6d3c                	ld	a5,88(a0)
    80002b3e:	67c8                	ld	a0,136(a5)
    80002b40:	b7dd                	j	80002b26 <argraw+0x34>
    return p->trapframe->a4;
    80002b42:	6d3c                	ld	a5,88(a0)
    80002b44:	6bc8                	ld	a0,144(a5)
    80002b46:	b7c5                	j	80002b26 <argraw+0x34>
    return p->trapframe->a5;
    80002b48:	6d3c                	ld	a5,88(a0)
    80002b4a:	6fc8                	ld	a0,152(a5)
    80002b4c:	bfe9                	j	80002b26 <argraw+0x34>
  panic("argraw");
    80002b4e:	00006517          	auipc	a0,0x6
    80002b52:	8fa50513          	addi	a0,a0,-1798 # 80008448 <syscalls+0xb0>
    80002b56:	ffffe097          	auipc	ra,0xffffe
    80002b5a:	a1e080e7          	jalr	-1506(ra) # 80000574 <panic>

0000000080002b5e <fetchaddr>:
{
    80002b5e:	1101                	addi	sp,sp,-32
    80002b60:	ec06                	sd	ra,24(sp)
    80002b62:	e822                	sd	s0,16(sp)
    80002b64:	e426                	sd	s1,8(sp)
    80002b66:	e04a                	sd	s2,0(sp)
    80002b68:	1000                	addi	s0,sp,32
    80002b6a:	84aa                	mv	s1,a0
    80002b6c:	892e                	mv	s2,a1
  struct proc *p = myproc();
    80002b6e:	fffff097          	auipc	ra,0xfffff
    80002b72:	f2a080e7          	jalr	-214(ra) # 80001a98 <myproc>
  if(addr >= p->sz || addr+sizeof(uint64) > p->sz)
    80002b76:	653c                	ld	a5,72(a0)
    80002b78:	02f4f963          	bleu	a5,s1,80002baa <fetchaddr+0x4c>
    80002b7c:	00848713          	addi	a4,s1,8
    80002b80:	02e7e763          	bltu	a5,a4,80002bae <fetchaddr+0x50>
  if(copyin(p->pagetable, (char *)ip, addr, sizeof(*ip)) != 0)
    80002b84:	46a1                	li	a3,8
    80002b86:	8626                	mv	a2,s1
    80002b88:	85ca                	mv	a1,s2
    80002b8a:	6928                	ld	a0,80(a0)
    80002b8c:	fffff097          	auipc	ra,0xfffff
    80002b90:	c74080e7          	jalr	-908(ra) # 80001800 <copyin>
    80002b94:	00a03533          	snez	a0,a0
    80002b98:	40a0053b          	negw	a0,a0
    80002b9c:	2501                	sext.w	a0,a0
}
    80002b9e:	60e2                	ld	ra,24(sp)
    80002ba0:	6442                	ld	s0,16(sp)
    80002ba2:	64a2                	ld	s1,8(sp)
    80002ba4:	6902                	ld	s2,0(sp)
    80002ba6:	6105                	addi	sp,sp,32
    80002ba8:	8082                	ret
    return -1;
    80002baa:	557d                	li	a0,-1
    80002bac:	bfcd                	j	80002b9e <fetchaddr+0x40>
    80002bae:	557d                	li	a0,-1
    80002bb0:	b7fd                	j	80002b9e <fetchaddr+0x40>

0000000080002bb2 <fetchstr>:
{
    80002bb2:	7179                	addi	sp,sp,-48
    80002bb4:	f406                	sd	ra,40(sp)
    80002bb6:	f022                	sd	s0,32(sp)
    80002bb8:	ec26                	sd	s1,24(sp)
    80002bba:	e84a                	sd	s2,16(sp)
    80002bbc:	e44e                	sd	s3,8(sp)
    80002bbe:	1800                	addi	s0,sp,48
    80002bc0:	892a                	mv	s2,a0
    80002bc2:	84ae                	mv	s1,a1
    80002bc4:	89b2                	mv	s3,a2
  struct proc *p = myproc();
    80002bc6:	fffff097          	auipc	ra,0xfffff
    80002bca:	ed2080e7          	jalr	-302(ra) # 80001a98 <myproc>
  int err = copyinstr(p->pagetable, buf, addr, max);
    80002bce:	86ce                	mv	a3,s3
    80002bd0:	864a                	mv	a2,s2
    80002bd2:	85a6                	mv	a1,s1
    80002bd4:	6928                	ld	a0,80(a0)
    80002bd6:	fffff097          	auipc	ra,0xfffff
    80002bda:	cb8080e7          	jalr	-840(ra) # 8000188e <copyinstr>
  if(err < 0)
    80002bde:	00054763          	bltz	a0,80002bec <fetchstr+0x3a>
  return strlen(buf);
    80002be2:	8526                	mv	a0,s1
    80002be4:	ffffe097          	auipc	ra,0xffffe
    80002be8:	324080e7          	jalr	804(ra) # 80000f08 <strlen>
}
    80002bec:	70a2                	ld	ra,40(sp)
    80002bee:	7402                	ld	s0,32(sp)
    80002bf0:	64e2                	ld	s1,24(sp)
    80002bf2:	6942                	ld	s2,16(sp)
    80002bf4:	69a2                	ld	s3,8(sp)
    80002bf6:	6145                	addi	sp,sp,48
    80002bf8:	8082                	ret

0000000080002bfa <argint>:

// Fetch the nth 32-bit system call argument.
int
argint(int n, int *ip)
{
    80002bfa:	1101                	addi	sp,sp,-32
    80002bfc:	ec06                	sd	ra,24(sp)
    80002bfe:	e822                	sd	s0,16(sp)
    80002c00:	e426                	sd	s1,8(sp)
    80002c02:	1000                	addi	s0,sp,32
    80002c04:	84ae                	mv	s1,a1
  *ip = argraw(n);
    80002c06:	00000097          	auipc	ra,0x0
    80002c0a:	eec080e7          	jalr	-276(ra) # 80002af2 <argraw>
    80002c0e:	c088                	sw	a0,0(s1)
  return 0;
}
    80002c10:	4501                	li	a0,0
    80002c12:	60e2                	ld	ra,24(sp)
    80002c14:	6442                	ld	s0,16(sp)
    80002c16:	64a2                	ld	s1,8(sp)
    80002c18:	6105                	addi	sp,sp,32
    80002c1a:	8082                	ret

0000000080002c1c <argaddr>:
// Retrieve an argument as a pointer.
// Doesn't check for legality, since
// copyin/copyout will do that.
int
argaddr(int n, uint64 *ip)
{
    80002c1c:	1101                	addi	sp,sp,-32
    80002c1e:	ec06                	sd	ra,24(sp)
    80002c20:	e822                	sd	s0,16(sp)
    80002c22:	e426                	sd	s1,8(sp)
    80002c24:	1000                	addi	s0,sp,32
    80002c26:	84ae                	mv	s1,a1
  *ip = argraw(n);
    80002c28:	00000097          	auipc	ra,0x0
    80002c2c:	eca080e7          	jalr	-310(ra) # 80002af2 <argraw>
    80002c30:	e088                	sd	a0,0(s1)
  return 0;
}
    80002c32:	4501                	li	a0,0
    80002c34:	60e2                	ld	ra,24(sp)
    80002c36:	6442                	ld	s0,16(sp)
    80002c38:	64a2                	ld	s1,8(sp)
    80002c3a:	6105                	addi	sp,sp,32
    80002c3c:	8082                	ret

0000000080002c3e <argstr>:
// Fetch the nth word-sized system call argument as a null-terminated string.
// Copies into buf, at most max.
// Returns string length if OK (including nul), -1 if error.
int
argstr(int n, char *buf, int max)
{
    80002c3e:	1101                	addi	sp,sp,-32
    80002c40:	ec06                	sd	ra,24(sp)
    80002c42:	e822                	sd	s0,16(sp)
    80002c44:	e426                	sd	s1,8(sp)
    80002c46:	e04a                	sd	s2,0(sp)
    80002c48:	1000                	addi	s0,sp,32
    80002c4a:	84ae                	mv	s1,a1
    80002c4c:	8932                	mv	s2,a2
  *ip = argraw(n);
    80002c4e:	00000097          	auipc	ra,0x0
    80002c52:	ea4080e7          	jalr	-348(ra) # 80002af2 <argraw>
  uint64 addr;
  if(argaddr(n, &addr) < 0)
    return -1;
  return fetchstr(addr, buf, max);
    80002c56:	864a                	mv	a2,s2
    80002c58:	85a6                	mv	a1,s1
    80002c5a:	00000097          	auipc	ra,0x0
    80002c5e:	f58080e7          	jalr	-168(ra) # 80002bb2 <fetchstr>
}
    80002c62:	60e2                	ld	ra,24(sp)
    80002c64:	6442                	ld	s0,16(sp)
    80002c66:	64a2                	ld	s1,8(sp)
    80002c68:	6902                	ld	s2,0(sp)
    80002c6a:	6105                	addi	sp,sp,32
    80002c6c:	8082                	ret

0000000080002c6e <syscall>:
[SYS_close]   sys_close,
};

void
syscall(void)
{
    80002c6e:	1101                	addi	sp,sp,-32
    80002c70:	ec06                	sd	ra,24(sp)
    80002c72:	e822                	sd	s0,16(sp)
    80002c74:	e426                	sd	s1,8(sp)
    80002c76:	e04a                	sd	s2,0(sp)
    80002c78:	1000                	addi	s0,sp,32
  int num;
  struct proc *p = myproc();
    80002c7a:	fffff097          	auipc	ra,0xfffff
    80002c7e:	e1e080e7          	jalr	-482(ra) # 80001a98 <myproc>
    80002c82:	84aa                	mv	s1,a0

  num = p->trapframe->a7;
    80002c84:	05853903          	ld	s2,88(a0)
    80002c88:	0a893783          	ld	a5,168(s2)
    80002c8c:	0007869b          	sext.w	a3,a5
  if(num > 0 && num < NELEM(syscalls) && syscalls[num]) {
    80002c90:	37fd                	addiw	a5,a5,-1
    80002c92:	4751                	li	a4,20
    80002c94:	00f76f63          	bltu	a4,a5,80002cb2 <syscall+0x44>
    80002c98:	00369713          	slli	a4,a3,0x3
    80002c9c:	00005797          	auipc	a5,0x5
    80002ca0:	6fc78793          	addi	a5,a5,1788 # 80008398 <syscalls>
    80002ca4:	97ba                	add	a5,a5,a4
    80002ca6:	639c                	ld	a5,0(a5)
    80002ca8:	c789                	beqz	a5,80002cb2 <syscall+0x44>
    p->trapframe->a0 = syscalls[num]();
    80002caa:	9782                	jalr	a5
    80002cac:	06a93823          	sd	a0,112(s2)
    80002cb0:	a839                	j	80002cce <syscall+0x60>
  } else {
    printf("%d %s: unknown sys call %d\n",
    80002cb2:	15848613          	addi	a2,s1,344
    80002cb6:	5c8c                	lw	a1,56(s1)
    80002cb8:	00005517          	auipc	a0,0x5
    80002cbc:	79850513          	addi	a0,a0,1944 # 80008450 <syscalls+0xb8>
    80002cc0:	ffffe097          	auipc	ra,0xffffe
    80002cc4:	8fe080e7          	jalr	-1794(ra) # 800005be <printf>
            p->pid, p->name, num);
    p->trapframe->a0 = -1;
    80002cc8:	6cbc                	ld	a5,88(s1)
    80002cca:	577d                	li	a4,-1
    80002ccc:	fbb8                	sd	a4,112(a5)
  }
}
    80002cce:	60e2                	ld	ra,24(sp)
    80002cd0:	6442                	ld	s0,16(sp)
    80002cd2:	64a2                	ld	s1,8(sp)
    80002cd4:	6902                	ld	s2,0(sp)
    80002cd6:	6105                	addi	sp,sp,32
    80002cd8:	8082                	ret

0000000080002cda <sys_exit>:
#include "spinlock.h"
#include "proc.h"

uint64
sys_exit(void)
{
    80002cda:	1101                	addi	sp,sp,-32
    80002cdc:	ec06                	sd	ra,24(sp)
    80002cde:	e822                	sd	s0,16(sp)
    80002ce0:	1000                	addi	s0,sp,32
  int n;
  if(argint(0, &n) < 0)
    80002ce2:	fec40593          	addi	a1,s0,-20
    80002ce6:	4501                	li	a0,0
    80002ce8:	00000097          	auipc	ra,0x0
    80002cec:	f12080e7          	jalr	-238(ra) # 80002bfa <argint>
    return -1;
    80002cf0:	57fd                	li	a5,-1
  if(argint(0, &n) < 0)
    80002cf2:	00054963          	bltz	a0,80002d04 <sys_exit+0x2a>
  exit(n);
    80002cf6:	fec42503          	lw	a0,-20(s0)
    80002cfa:	fffff097          	auipc	ra,0xfffff
    80002cfe:	470080e7          	jalr	1136(ra) # 8000216a <exit>
  return 0;  // not reached
    80002d02:	4781                	li	a5,0
}
    80002d04:	853e                	mv	a0,a5
    80002d06:	60e2                	ld	ra,24(sp)
    80002d08:	6442                	ld	s0,16(sp)
    80002d0a:	6105                	addi	sp,sp,32
    80002d0c:	8082                	ret

0000000080002d0e <sys_getpid>:

uint64
sys_getpid(void)
{
    80002d0e:	1141                	addi	sp,sp,-16
    80002d10:	e406                	sd	ra,8(sp)
    80002d12:	e022                	sd	s0,0(sp)
    80002d14:	0800                	addi	s0,sp,16
  return myproc()->pid;
    80002d16:	fffff097          	auipc	ra,0xfffff
    80002d1a:	d82080e7          	jalr	-638(ra) # 80001a98 <myproc>
}
    80002d1e:	5d08                	lw	a0,56(a0)
    80002d20:	60a2                	ld	ra,8(sp)
    80002d22:	6402                	ld	s0,0(sp)
    80002d24:	0141                	addi	sp,sp,16
    80002d26:	8082                	ret

0000000080002d28 <sys_fork>:

uint64
sys_fork(void)
{
    80002d28:	1141                	addi	sp,sp,-16
    80002d2a:	e406                	sd	ra,8(sp)
    80002d2c:	e022                	sd	s0,0(sp)
    80002d2e:	0800                	addi	s0,sp,16
  return fork();
    80002d30:	fffff097          	auipc	ra,0xfffff
    80002d34:	12e080e7          	jalr	302(ra) # 80001e5e <fork>
}
    80002d38:	60a2                	ld	ra,8(sp)
    80002d3a:	6402                	ld	s0,0(sp)
    80002d3c:	0141                	addi	sp,sp,16
    80002d3e:	8082                	ret

0000000080002d40 <sys_wait>:

uint64
sys_wait(void)
{
    80002d40:	1101                	addi	sp,sp,-32
    80002d42:	ec06                	sd	ra,24(sp)
    80002d44:	e822                	sd	s0,16(sp)
    80002d46:	1000                	addi	s0,sp,32
  uint64 p;
  if(argaddr(0, &p) < 0)
    80002d48:	fe840593          	addi	a1,s0,-24
    80002d4c:	4501                	li	a0,0
    80002d4e:	00000097          	auipc	ra,0x0
    80002d52:	ece080e7          	jalr	-306(ra) # 80002c1c <argaddr>
    return -1;
    80002d56:	57fd                	li	a5,-1
  if(argaddr(0, &p) < 0)
    80002d58:	00054963          	bltz	a0,80002d6a <sys_wait+0x2a>
  return wait(p);
    80002d5c:	fe843503          	ld	a0,-24(s0)
    80002d60:	fffff097          	auipc	ra,0xfffff
    80002d64:	5d0080e7          	jalr	1488(ra) # 80002330 <wait>
    80002d68:	87aa                	mv	a5,a0
}
    80002d6a:	853e                	mv	a0,a5
    80002d6c:	60e2                	ld	ra,24(sp)
    80002d6e:	6442                	ld	s0,16(sp)
    80002d70:	6105                	addi	sp,sp,32
    80002d72:	8082                	ret

0000000080002d74 <sys_sbrk>:

uint64
sys_sbrk(void)
{
    80002d74:	7179                	addi	sp,sp,-48
    80002d76:	f406                	sd	ra,40(sp)
    80002d78:	f022                	sd	s0,32(sp)
    80002d7a:	ec26                	sd	s1,24(sp)
    80002d7c:	1800                	addi	s0,sp,48
  int addr;
  int n;

  if(argint(0, &n) < 0)
    80002d7e:	fdc40593          	addi	a1,s0,-36
    80002d82:	4501                	li	a0,0
    80002d84:	00000097          	auipc	ra,0x0
    80002d88:	e76080e7          	jalr	-394(ra) # 80002bfa <argint>
    return -1;
    80002d8c:	54fd                	li	s1,-1
  if(argint(0, &n) < 0)
    80002d8e:	02054363          	bltz	a0,80002db4 <sys_sbrk+0x40>

  struct proc *p = myproc(); 
    80002d92:	fffff097          	auipc	ra,0xfffff
    80002d96:	d06080e7          	jalr	-762(ra) # 80001a98 <myproc>
  addr = p->sz;
    80002d9a:	6538                	ld	a4,72(a0)
    80002d9c:	0007049b          	sext.w	s1,a4
  if (addr + n >= MAXVA || addr + n <= 0) {
    80002da0:	fdc42783          	lw	a5,-36(s0)
    80002da4:	009786bb          	addw	a3,a5,s1
    80002da8:	00d05663          	blez	a3,80002db4 <sys_sbrk+0x40>
    return addr;
  }
  if(n <= 0 ) {
    80002dac:	00f05a63          	blez	a5,80002dc0 <sys_sbrk+0x4c>
    if(growproc(n) < 0)
      return -1;
  } else {
    p->sz += n;
    80002db0:	97ba                	add	a5,a5,a4
    80002db2:	e53c                	sd	a5,72(a0)
  }
  //if(growproc(n) < 0)
  //  return -1;
  return addr;
}
    80002db4:	8526                	mv	a0,s1
    80002db6:	70a2                	ld	ra,40(sp)
    80002db8:	7402                	ld	s0,32(sp)
    80002dba:	64e2                	ld	s1,24(sp)
    80002dbc:	6145                	addi	sp,sp,48
    80002dbe:	8082                	ret
    if(growproc(n) < 0)
    80002dc0:	853e                	mv	a0,a5
    80002dc2:	fffff097          	auipc	ra,0xfffff
    80002dc6:	024080e7          	jalr	36(ra) # 80001de6 <growproc>
    80002dca:	fe0555e3          	bgez	a0,80002db4 <sys_sbrk+0x40>
      return -1;
    80002dce:	54fd                	li	s1,-1
    80002dd0:	b7d5                	j	80002db4 <sys_sbrk+0x40>

0000000080002dd2 <sys_sleep>:

uint64
sys_sleep(void)
{
    80002dd2:	7139                	addi	sp,sp,-64
    80002dd4:	fc06                	sd	ra,56(sp)
    80002dd6:	f822                	sd	s0,48(sp)
    80002dd8:	f426                	sd	s1,40(sp)
    80002dda:	f04a                	sd	s2,32(sp)
    80002ddc:	ec4e                	sd	s3,24(sp)
    80002dde:	0080                	addi	s0,sp,64
  int n;
  uint ticks0;

  if(argint(0, &n) < 0)
    80002de0:	fcc40593          	addi	a1,s0,-52
    80002de4:	4501                	li	a0,0
    80002de6:	00000097          	auipc	ra,0x0
    80002dea:	e14080e7          	jalr	-492(ra) # 80002bfa <argint>
    return -1;
    80002dee:	57fd                	li	a5,-1
  if(argint(0, &n) < 0)
    80002df0:	06054763          	bltz	a0,80002e5e <sys_sleep+0x8c>
  acquire(&tickslock);
    80002df4:	00015517          	auipc	a0,0x15
    80002df8:	97450513          	addi	a0,a0,-1676 # 80017768 <tickslock>
    80002dfc:	ffffe097          	auipc	ra,0xffffe
    80002e00:	e66080e7          	jalr	-410(ra) # 80000c62 <acquire>
  ticks0 = ticks;
    80002e04:	00006797          	auipc	a5,0x6
    80002e08:	21c78793          	addi	a5,a5,540 # 80009020 <ticks>
    80002e0c:	0007a903          	lw	s2,0(a5)
  while(ticks - ticks0 < n){
    80002e10:	fcc42783          	lw	a5,-52(s0)
    80002e14:	cf85                	beqz	a5,80002e4c <sys_sleep+0x7a>
    if(myproc()->killed){
      release(&tickslock);
      return -1;
    }
    sleep(&ticks, &tickslock);
    80002e16:	00015997          	auipc	s3,0x15
    80002e1a:	95298993          	addi	s3,s3,-1710 # 80017768 <tickslock>
    80002e1e:	00006497          	auipc	s1,0x6
    80002e22:	20248493          	addi	s1,s1,514 # 80009020 <ticks>
    if(myproc()->killed){
    80002e26:	fffff097          	auipc	ra,0xfffff
    80002e2a:	c72080e7          	jalr	-910(ra) # 80001a98 <myproc>
    80002e2e:	591c                	lw	a5,48(a0)
    80002e30:	ef9d                	bnez	a5,80002e6e <sys_sleep+0x9c>
    sleep(&ticks, &tickslock);
    80002e32:	85ce                	mv	a1,s3
    80002e34:	8526                	mv	a0,s1
    80002e36:	fffff097          	auipc	ra,0xfffff
    80002e3a:	47c080e7          	jalr	1148(ra) # 800022b2 <sleep>
  while(ticks - ticks0 < n){
    80002e3e:	409c                	lw	a5,0(s1)
    80002e40:	412787bb          	subw	a5,a5,s2
    80002e44:	fcc42703          	lw	a4,-52(s0)
    80002e48:	fce7efe3          	bltu	a5,a4,80002e26 <sys_sleep+0x54>
  }
  release(&tickslock);
    80002e4c:	00015517          	auipc	a0,0x15
    80002e50:	91c50513          	addi	a0,a0,-1764 # 80017768 <tickslock>
    80002e54:	ffffe097          	auipc	ra,0xffffe
    80002e58:	ec2080e7          	jalr	-318(ra) # 80000d16 <release>
  return 0;
    80002e5c:	4781                	li	a5,0
}
    80002e5e:	853e                	mv	a0,a5
    80002e60:	70e2                	ld	ra,56(sp)
    80002e62:	7442                	ld	s0,48(sp)
    80002e64:	74a2                	ld	s1,40(sp)
    80002e66:	7902                	ld	s2,32(sp)
    80002e68:	69e2                	ld	s3,24(sp)
    80002e6a:	6121                	addi	sp,sp,64
    80002e6c:	8082                	ret
      release(&tickslock);
    80002e6e:	00015517          	auipc	a0,0x15
    80002e72:	8fa50513          	addi	a0,a0,-1798 # 80017768 <tickslock>
    80002e76:	ffffe097          	auipc	ra,0xffffe
    80002e7a:	ea0080e7          	jalr	-352(ra) # 80000d16 <release>
      return -1;
    80002e7e:	57fd                	li	a5,-1
    80002e80:	bff9                	j	80002e5e <sys_sleep+0x8c>

0000000080002e82 <sys_kill>:

uint64
sys_kill(void)
{
    80002e82:	1101                	addi	sp,sp,-32
    80002e84:	ec06                	sd	ra,24(sp)
    80002e86:	e822                	sd	s0,16(sp)
    80002e88:	1000                	addi	s0,sp,32
  int pid;

  if(argint(0, &pid) < 0)
    80002e8a:	fec40593          	addi	a1,s0,-20
    80002e8e:	4501                	li	a0,0
    80002e90:	00000097          	auipc	ra,0x0
    80002e94:	d6a080e7          	jalr	-662(ra) # 80002bfa <argint>
    return -1;
    80002e98:	57fd                	li	a5,-1
  if(argint(0, &pid) < 0)
    80002e9a:	00054963          	bltz	a0,80002eac <sys_kill+0x2a>
  return kill(pid);
    80002e9e:	fec42503          	lw	a0,-20(s0)
    80002ea2:	fffff097          	auipc	ra,0xfffff
    80002ea6:	600080e7          	jalr	1536(ra) # 800024a2 <kill>
    80002eaa:	87aa                	mv	a5,a0
}
    80002eac:	853e                	mv	a0,a5
    80002eae:	60e2                	ld	ra,24(sp)
    80002eb0:	6442                	ld	s0,16(sp)
    80002eb2:	6105                	addi	sp,sp,32
    80002eb4:	8082                	ret

0000000080002eb6 <sys_uptime>:

// return how many clock tick interrupts have occurred
// since start.
uint64
sys_uptime(void)
{
    80002eb6:	1101                	addi	sp,sp,-32
    80002eb8:	ec06                	sd	ra,24(sp)
    80002eba:	e822                	sd	s0,16(sp)
    80002ebc:	e426                	sd	s1,8(sp)
    80002ebe:	1000                	addi	s0,sp,32
  uint xticks;

  acquire(&tickslock);
    80002ec0:	00015517          	auipc	a0,0x15
    80002ec4:	8a850513          	addi	a0,a0,-1880 # 80017768 <tickslock>
    80002ec8:	ffffe097          	auipc	ra,0xffffe
    80002ecc:	d9a080e7          	jalr	-614(ra) # 80000c62 <acquire>
  xticks = ticks;
    80002ed0:	00006797          	auipc	a5,0x6
    80002ed4:	15078793          	addi	a5,a5,336 # 80009020 <ticks>
    80002ed8:	4384                	lw	s1,0(a5)
  release(&tickslock);
    80002eda:	00015517          	auipc	a0,0x15
    80002ede:	88e50513          	addi	a0,a0,-1906 # 80017768 <tickslock>
    80002ee2:	ffffe097          	auipc	ra,0xffffe
    80002ee6:	e34080e7          	jalr	-460(ra) # 80000d16 <release>
  return xticks;
}
    80002eea:	02049513          	slli	a0,s1,0x20
    80002eee:	9101                	srli	a0,a0,0x20
    80002ef0:	60e2                	ld	ra,24(sp)
    80002ef2:	6442                	ld	s0,16(sp)
    80002ef4:	64a2                	ld	s1,8(sp)
    80002ef6:	6105                	addi	sp,sp,32
    80002ef8:	8082                	ret

0000000080002efa <binit>:
  struct buf head;
} bcache;

void
binit(void)
{
    80002efa:	7179                	addi	sp,sp,-48
    80002efc:	f406                	sd	ra,40(sp)
    80002efe:	f022                	sd	s0,32(sp)
    80002f00:	ec26                	sd	s1,24(sp)
    80002f02:	e84a                	sd	s2,16(sp)
    80002f04:	e44e                	sd	s3,8(sp)
    80002f06:	e052                	sd	s4,0(sp)
    80002f08:	1800                	addi	s0,sp,48
  struct buf *b;

  initlock(&bcache.lock, "bcache");
    80002f0a:	00005597          	auipc	a1,0x5
    80002f0e:	56658593          	addi	a1,a1,1382 # 80008470 <syscalls+0xd8>
    80002f12:	00015517          	auipc	a0,0x15
    80002f16:	86e50513          	addi	a0,a0,-1938 # 80017780 <bcache>
    80002f1a:	ffffe097          	auipc	ra,0xffffe
    80002f1e:	cb8080e7          	jalr	-840(ra) # 80000bd2 <initlock>

  // Create linked list of buffers
  bcache.head.prev = &bcache.head;
    80002f22:	0001d797          	auipc	a5,0x1d
    80002f26:	85e78793          	addi	a5,a5,-1954 # 8001f780 <bcache+0x8000>
    80002f2a:	0001d717          	auipc	a4,0x1d
    80002f2e:	abe70713          	addi	a4,a4,-1346 # 8001f9e8 <bcache+0x8268>
    80002f32:	2ae7b823          	sd	a4,688(a5)
  bcache.head.next = &bcache.head;
    80002f36:	2ae7bc23          	sd	a4,696(a5)
  for(b = bcache.buf; b < bcache.buf+NBUF; b++){
    80002f3a:	00015497          	auipc	s1,0x15
    80002f3e:	85e48493          	addi	s1,s1,-1954 # 80017798 <bcache+0x18>
    b->next = bcache.head.next;
    80002f42:	893e                	mv	s2,a5
    b->prev = &bcache.head;
    80002f44:	89ba                	mv	s3,a4
    initsleeplock(&b->lock, "buffer");
    80002f46:	00005a17          	auipc	s4,0x5
    80002f4a:	532a0a13          	addi	s4,s4,1330 # 80008478 <syscalls+0xe0>
    b->next = bcache.head.next;
    80002f4e:	2b893783          	ld	a5,696(s2)
    80002f52:	e8bc                	sd	a5,80(s1)
    b->prev = &bcache.head;
    80002f54:	0534b423          	sd	s3,72(s1)
    initsleeplock(&b->lock, "buffer");
    80002f58:	85d2                	mv	a1,s4
    80002f5a:	01048513          	addi	a0,s1,16
    80002f5e:	00001097          	auipc	ra,0x1
    80002f62:	51e080e7          	jalr	1310(ra) # 8000447c <initsleeplock>
    bcache.head.next->prev = b;
    80002f66:	2b893783          	ld	a5,696(s2)
    80002f6a:	e7a4                	sd	s1,72(a5)
    bcache.head.next = b;
    80002f6c:	2a993c23          	sd	s1,696(s2)
  for(b = bcache.buf; b < bcache.buf+NBUF; b++){
    80002f70:	45848493          	addi	s1,s1,1112
    80002f74:	fd349de3          	bne	s1,s3,80002f4e <binit+0x54>
  }
}
    80002f78:	70a2                	ld	ra,40(sp)
    80002f7a:	7402                	ld	s0,32(sp)
    80002f7c:	64e2                	ld	s1,24(sp)
    80002f7e:	6942                	ld	s2,16(sp)
    80002f80:	69a2                	ld	s3,8(sp)
    80002f82:	6a02                	ld	s4,0(sp)
    80002f84:	6145                	addi	sp,sp,48
    80002f86:	8082                	ret

0000000080002f88 <bread>:
}

// Return a locked buf with the contents of the indicated block.
struct buf*
bread(uint dev, uint blockno)
{
    80002f88:	7179                	addi	sp,sp,-48
    80002f8a:	f406                	sd	ra,40(sp)
    80002f8c:	f022                	sd	s0,32(sp)
    80002f8e:	ec26                	sd	s1,24(sp)
    80002f90:	e84a                	sd	s2,16(sp)
    80002f92:	e44e                	sd	s3,8(sp)
    80002f94:	1800                	addi	s0,sp,48
    80002f96:	89aa                	mv	s3,a0
    80002f98:	892e                	mv	s2,a1
  acquire(&bcache.lock);
    80002f9a:	00014517          	auipc	a0,0x14
    80002f9e:	7e650513          	addi	a0,a0,2022 # 80017780 <bcache>
    80002fa2:	ffffe097          	auipc	ra,0xffffe
    80002fa6:	cc0080e7          	jalr	-832(ra) # 80000c62 <acquire>
  for(b = bcache.head.next; b != &bcache.head; b = b->next){
    80002faa:	0001c797          	auipc	a5,0x1c
    80002fae:	7d678793          	addi	a5,a5,2006 # 8001f780 <bcache+0x8000>
    80002fb2:	2b87b483          	ld	s1,696(a5)
    80002fb6:	0001d797          	auipc	a5,0x1d
    80002fba:	a3278793          	addi	a5,a5,-1486 # 8001f9e8 <bcache+0x8268>
    80002fbe:	02f48f63          	beq	s1,a5,80002ffc <bread+0x74>
    80002fc2:	873e                	mv	a4,a5
    80002fc4:	a021                	j	80002fcc <bread+0x44>
    80002fc6:	68a4                	ld	s1,80(s1)
    80002fc8:	02e48a63          	beq	s1,a4,80002ffc <bread+0x74>
    if(b->dev == dev && b->blockno == blockno){
    80002fcc:	449c                	lw	a5,8(s1)
    80002fce:	ff379ce3          	bne	a5,s3,80002fc6 <bread+0x3e>
    80002fd2:	44dc                	lw	a5,12(s1)
    80002fd4:	ff2799e3          	bne	a5,s2,80002fc6 <bread+0x3e>
      b->refcnt++;
    80002fd8:	40bc                	lw	a5,64(s1)
    80002fda:	2785                	addiw	a5,a5,1
    80002fdc:	c0bc                	sw	a5,64(s1)
      release(&bcache.lock);
    80002fde:	00014517          	auipc	a0,0x14
    80002fe2:	7a250513          	addi	a0,a0,1954 # 80017780 <bcache>
    80002fe6:	ffffe097          	auipc	ra,0xffffe
    80002fea:	d30080e7          	jalr	-720(ra) # 80000d16 <release>
      acquiresleep(&b->lock);
    80002fee:	01048513          	addi	a0,s1,16
    80002ff2:	00001097          	auipc	ra,0x1
    80002ff6:	4c4080e7          	jalr	1220(ra) # 800044b6 <acquiresleep>
      return b;
    80002ffa:	a8b1                	j	80003056 <bread+0xce>
  for(b = bcache.head.prev; b != &bcache.head; b = b->prev){
    80002ffc:	0001c797          	auipc	a5,0x1c
    80003000:	78478793          	addi	a5,a5,1924 # 8001f780 <bcache+0x8000>
    80003004:	2b07b483          	ld	s1,688(a5)
    80003008:	0001d797          	auipc	a5,0x1d
    8000300c:	9e078793          	addi	a5,a5,-1568 # 8001f9e8 <bcache+0x8268>
    80003010:	04f48d63          	beq	s1,a5,8000306a <bread+0xe2>
    if(b->refcnt == 0) {
    80003014:	40bc                	lw	a5,64(s1)
    80003016:	cb91                	beqz	a5,8000302a <bread+0xa2>
  for(b = bcache.head.prev; b != &bcache.head; b = b->prev){
    80003018:	0001d717          	auipc	a4,0x1d
    8000301c:	9d070713          	addi	a4,a4,-1584 # 8001f9e8 <bcache+0x8268>
    80003020:	64a4                	ld	s1,72(s1)
    80003022:	04e48463          	beq	s1,a4,8000306a <bread+0xe2>
    if(b->refcnt == 0) {
    80003026:	40bc                	lw	a5,64(s1)
    80003028:	ffe5                	bnez	a5,80003020 <bread+0x98>
      b->dev = dev;
    8000302a:	0134a423          	sw	s3,8(s1)
      b->blockno = blockno;
    8000302e:	0124a623          	sw	s2,12(s1)
      b->valid = 0;
    80003032:	0004a023          	sw	zero,0(s1)
      b->refcnt = 1;
    80003036:	4785                	li	a5,1
    80003038:	c0bc                	sw	a5,64(s1)
      release(&bcache.lock);
    8000303a:	00014517          	auipc	a0,0x14
    8000303e:	74650513          	addi	a0,a0,1862 # 80017780 <bcache>
    80003042:	ffffe097          	auipc	ra,0xffffe
    80003046:	cd4080e7          	jalr	-812(ra) # 80000d16 <release>
      acquiresleep(&b->lock);
    8000304a:	01048513          	addi	a0,s1,16
    8000304e:	00001097          	auipc	ra,0x1
    80003052:	468080e7          	jalr	1128(ra) # 800044b6 <acquiresleep>
  struct buf *b;

  b = bget(dev, blockno);
  if(!b->valid) {
    80003056:	409c                	lw	a5,0(s1)
    80003058:	c38d                	beqz	a5,8000307a <bread+0xf2>
    virtio_disk_rw(b, 0);
    b->valid = 1;
  }
  return b;
}
    8000305a:	8526                	mv	a0,s1
    8000305c:	70a2                	ld	ra,40(sp)
    8000305e:	7402                	ld	s0,32(sp)
    80003060:	64e2                	ld	s1,24(sp)
    80003062:	6942                	ld	s2,16(sp)
    80003064:	69a2                	ld	s3,8(sp)
    80003066:	6145                	addi	sp,sp,48
    80003068:	8082                	ret
  panic("bget: no buffers");
    8000306a:	00005517          	auipc	a0,0x5
    8000306e:	41650513          	addi	a0,a0,1046 # 80008480 <syscalls+0xe8>
    80003072:	ffffd097          	auipc	ra,0xffffd
    80003076:	502080e7          	jalr	1282(ra) # 80000574 <panic>
    virtio_disk_rw(b, 0);
    8000307a:	4581                	li	a1,0
    8000307c:	8526                	mv	a0,s1
    8000307e:	00003097          	auipc	ra,0x3
    80003082:	ff0080e7          	jalr	-16(ra) # 8000606e <virtio_disk_rw>
    b->valid = 1;
    80003086:	4785                	li	a5,1
    80003088:	c09c                	sw	a5,0(s1)
  return b;
    8000308a:	bfc1                	j	8000305a <bread+0xd2>

000000008000308c <bwrite>:

// Write b's contents to disk.  Must be locked.
void
bwrite(struct buf *b)
{
    8000308c:	1101                	addi	sp,sp,-32
    8000308e:	ec06                	sd	ra,24(sp)
    80003090:	e822                	sd	s0,16(sp)
    80003092:	e426                	sd	s1,8(sp)
    80003094:	1000                	addi	s0,sp,32
    80003096:	84aa                	mv	s1,a0
  if(!holdingsleep(&b->lock))
    80003098:	0541                	addi	a0,a0,16
    8000309a:	00001097          	auipc	ra,0x1
    8000309e:	4b6080e7          	jalr	1206(ra) # 80004550 <holdingsleep>
    800030a2:	cd01                	beqz	a0,800030ba <bwrite+0x2e>
    panic("bwrite");
  virtio_disk_rw(b, 1);
    800030a4:	4585                	li	a1,1
    800030a6:	8526                	mv	a0,s1
    800030a8:	00003097          	auipc	ra,0x3
    800030ac:	fc6080e7          	jalr	-58(ra) # 8000606e <virtio_disk_rw>
}
    800030b0:	60e2                	ld	ra,24(sp)
    800030b2:	6442                	ld	s0,16(sp)
    800030b4:	64a2                	ld	s1,8(sp)
    800030b6:	6105                	addi	sp,sp,32
    800030b8:	8082                	ret
    panic("bwrite");
    800030ba:	00005517          	auipc	a0,0x5
    800030be:	3de50513          	addi	a0,a0,990 # 80008498 <syscalls+0x100>
    800030c2:	ffffd097          	auipc	ra,0xffffd
    800030c6:	4b2080e7          	jalr	1202(ra) # 80000574 <panic>

00000000800030ca <brelse>:

// Release a locked buffer.
// Move to the head of the most-recently-used list.
void
brelse(struct buf *b)
{
    800030ca:	1101                	addi	sp,sp,-32
    800030cc:	ec06                	sd	ra,24(sp)
    800030ce:	e822                	sd	s0,16(sp)
    800030d0:	e426                	sd	s1,8(sp)
    800030d2:	e04a                	sd	s2,0(sp)
    800030d4:	1000                	addi	s0,sp,32
    800030d6:	84aa                	mv	s1,a0
  if(!holdingsleep(&b->lock))
    800030d8:	01050913          	addi	s2,a0,16
    800030dc:	854a                	mv	a0,s2
    800030de:	00001097          	auipc	ra,0x1
    800030e2:	472080e7          	jalr	1138(ra) # 80004550 <holdingsleep>
    800030e6:	c92d                	beqz	a0,80003158 <brelse+0x8e>
    panic("brelse");

  releasesleep(&b->lock);
    800030e8:	854a                	mv	a0,s2
    800030ea:	00001097          	auipc	ra,0x1
    800030ee:	422080e7          	jalr	1058(ra) # 8000450c <releasesleep>

  acquire(&bcache.lock);
    800030f2:	00014517          	auipc	a0,0x14
    800030f6:	68e50513          	addi	a0,a0,1678 # 80017780 <bcache>
    800030fa:	ffffe097          	auipc	ra,0xffffe
    800030fe:	b68080e7          	jalr	-1176(ra) # 80000c62 <acquire>
  b->refcnt--;
    80003102:	40bc                	lw	a5,64(s1)
    80003104:	37fd                	addiw	a5,a5,-1
    80003106:	0007871b          	sext.w	a4,a5
    8000310a:	c0bc                	sw	a5,64(s1)
  if (b->refcnt == 0) {
    8000310c:	eb05                	bnez	a4,8000313c <brelse+0x72>
    // no one is waiting for it.
    b->next->prev = b->prev;
    8000310e:	68bc                	ld	a5,80(s1)
    80003110:	64b8                	ld	a4,72(s1)
    80003112:	e7b8                	sd	a4,72(a5)
    b->prev->next = b->next;
    80003114:	64bc                	ld	a5,72(s1)
    80003116:	68b8                	ld	a4,80(s1)
    80003118:	ebb8                	sd	a4,80(a5)
    b->next = bcache.head.next;
    8000311a:	0001c797          	auipc	a5,0x1c
    8000311e:	66678793          	addi	a5,a5,1638 # 8001f780 <bcache+0x8000>
    80003122:	2b87b703          	ld	a4,696(a5)
    80003126:	e8b8                	sd	a4,80(s1)
    b->prev = &bcache.head;
    80003128:	0001d717          	auipc	a4,0x1d
    8000312c:	8c070713          	addi	a4,a4,-1856 # 8001f9e8 <bcache+0x8268>
    80003130:	e4b8                	sd	a4,72(s1)
    bcache.head.next->prev = b;
    80003132:	2b87b703          	ld	a4,696(a5)
    80003136:	e724                	sd	s1,72(a4)
    bcache.head.next = b;
    80003138:	2a97bc23          	sd	s1,696(a5)
  }
  
  release(&bcache.lock);
    8000313c:	00014517          	auipc	a0,0x14
    80003140:	64450513          	addi	a0,a0,1604 # 80017780 <bcache>
    80003144:	ffffe097          	auipc	ra,0xffffe
    80003148:	bd2080e7          	jalr	-1070(ra) # 80000d16 <release>
}
    8000314c:	60e2                	ld	ra,24(sp)
    8000314e:	6442                	ld	s0,16(sp)
    80003150:	64a2                	ld	s1,8(sp)
    80003152:	6902                	ld	s2,0(sp)
    80003154:	6105                	addi	sp,sp,32
    80003156:	8082                	ret
    panic("brelse");
    80003158:	00005517          	auipc	a0,0x5
    8000315c:	34850513          	addi	a0,a0,840 # 800084a0 <syscalls+0x108>
    80003160:	ffffd097          	auipc	ra,0xffffd
    80003164:	414080e7          	jalr	1044(ra) # 80000574 <panic>

0000000080003168 <bpin>:

void
bpin(struct buf *b) {
    80003168:	1101                	addi	sp,sp,-32
    8000316a:	ec06                	sd	ra,24(sp)
    8000316c:	e822                	sd	s0,16(sp)
    8000316e:	e426                	sd	s1,8(sp)
    80003170:	1000                	addi	s0,sp,32
    80003172:	84aa                	mv	s1,a0
  acquire(&bcache.lock);
    80003174:	00014517          	auipc	a0,0x14
    80003178:	60c50513          	addi	a0,a0,1548 # 80017780 <bcache>
    8000317c:	ffffe097          	auipc	ra,0xffffe
    80003180:	ae6080e7          	jalr	-1306(ra) # 80000c62 <acquire>
  b->refcnt++;
    80003184:	40bc                	lw	a5,64(s1)
    80003186:	2785                	addiw	a5,a5,1
    80003188:	c0bc                	sw	a5,64(s1)
  release(&bcache.lock);
    8000318a:	00014517          	auipc	a0,0x14
    8000318e:	5f650513          	addi	a0,a0,1526 # 80017780 <bcache>
    80003192:	ffffe097          	auipc	ra,0xffffe
    80003196:	b84080e7          	jalr	-1148(ra) # 80000d16 <release>
}
    8000319a:	60e2                	ld	ra,24(sp)
    8000319c:	6442                	ld	s0,16(sp)
    8000319e:	64a2                	ld	s1,8(sp)
    800031a0:	6105                	addi	sp,sp,32
    800031a2:	8082                	ret

00000000800031a4 <bunpin>:

void
bunpin(struct buf *b) {
    800031a4:	1101                	addi	sp,sp,-32
    800031a6:	ec06                	sd	ra,24(sp)
    800031a8:	e822                	sd	s0,16(sp)
    800031aa:	e426                	sd	s1,8(sp)
    800031ac:	1000                	addi	s0,sp,32
    800031ae:	84aa                	mv	s1,a0
  acquire(&bcache.lock);
    800031b0:	00014517          	auipc	a0,0x14
    800031b4:	5d050513          	addi	a0,a0,1488 # 80017780 <bcache>
    800031b8:	ffffe097          	auipc	ra,0xffffe
    800031bc:	aaa080e7          	jalr	-1366(ra) # 80000c62 <acquire>
  b->refcnt--;
    800031c0:	40bc                	lw	a5,64(s1)
    800031c2:	37fd                	addiw	a5,a5,-1
    800031c4:	c0bc                	sw	a5,64(s1)
  release(&bcache.lock);
    800031c6:	00014517          	auipc	a0,0x14
    800031ca:	5ba50513          	addi	a0,a0,1466 # 80017780 <bcache>
    800031ce:	ffffe097          	auipc	ra,0xffffe
    800031d2:	b48080e7          	jalr	-1208(ra) # 80000d16 <release>
}
    800031d6:	60e2                	ld	ra,24(sp)
    800031d8:	6442                	ld	s0,16(sp)
    800031da:	64a2                	ld	s1,8(sp)
    800031dc:	6105                	addi	sp,sp,32
    800031de:	8082                	ret

00000000800031e0 <bfree>:
}

// Free a disk block.
static void
bfree(int dev, uint b)
{
    800031e0:	1101                	addi	sp,sp,-32
    800031e2:	ec06                	sd	ra,24(sp)
    800031e4:	e822                	sd	s0,16(sp)
    800031e6:	e426                	sd	s1,8(sp)
    800031e8:	e04a                	sd	s2,0(sp)
    800031ea:	1000                	addi	s0,sp,32
    800031ec:	84ae                	mv	s1,a1
  struct buf *bp;
  int bi, m;

  bp = bread(dev, BBLOCK(b, sb));
    800031ee:	00d5d59b          	srliw	a1,a1,0xd
    800031f2:	0001d797          	auipc	a5,0x1d
    800031f6:	c4e78793          	addi	a5,a5,-946 # 8001fe40 <sb>
    800031fa:	4fdc                	lw	a5,28(a5)
    800031fc:	9dbd                	addw	a1,a1,a5
    800031fe:	00000097          	auipc	ra,0x0
    80003202:	d8a080e7          	jalr	-630(ra) # 80002f88 <bread>
  bi = b % BPB;
    80003206:	2481                	sext.w	s1,s1
  m = 1 << (bi % 8);
    80003208:	0074f793          	andi	a5,s1,7
    8000320c:	4705                	li	a4,1
    8000320e:	00f7173b          	sllw	a4,a4,a5
  bi = b % BPB;
    80003212:	6789                	lui	a5,0x2
    80003214:	17fd                	addi	a5,a5,-1
    80003216:	8cfd                	and	s1,s1,a5
  if((bp->data[bi/8] & m) == 0)
    80003218:	41f4d79b          	sraiw	a5,s1,0x1f
    8000321c:	01d7d79b          	srliw	a5,a5,0x1d
    80003220:	9fa5                	addw	a5,a5,s1
    80003222:	4037d79b          	sraiw	a5,a5,0x3
    80003226:	00f506b3          	add	a3,a0,a5
    8000322a:	0586c683          	lbu	a3,88(a3)
    8000322e:	00d77633          	and	a2,a4,a3
    80003232:	c61d                	beqz	a2,80003260 <bfree+0x80>
    80003234:	892a                	mv	s2,a0
    panic("freeing free block");
  bp->data[bi/8] &= ~m;
    80003236:	97aa                	add	a5,a5,a0
    80003238:	fff74713          	not	a4,a4
    8000323c:	8f75                	and	a4,a4,a3
    8000323e:	04e78c23          	sb	a4,88(a5) # 2058 <_entry-0x7fffdfa8>
  log_write(bp);
    80003242:	00001097          	auipc	ra,0x1
    80003246:	136080e7          	jalr	310(ra) # 80004378 <log_write>
  brelse(bp);
    8000324a:	854a                	mv	a0,s2
    8000324c:	00000097          	auipc	ra,0x0
    80003250:	e7e080e7          	jalr	-386(ra) # 800030ca <brelse>
}
    80003254:	60e2                	ld	ra,24(sp)
    80003256:	6442                	ld	s0,16(sp)
    80003258:	64a2                	ld	s1,8(sp)
    8000325a:	6902                	ld	s2,0(sp)
    8000325c:	6105                	addi	sp,sp,32
    8000325e:	8082                	ret
    panic("freeing free block");
    80003260:	00005517          	auipc	a0,0x5
    80003264:	24850513          	addi	a0,a0,584 # 800084a8 <syscalls+0x110>
    80003268:	ffffd097          	auipc	ra,0xffffd
    8000326c:	30c080e7          	jalr	780(ra) # 80000574 <panic>

0000000080003270 <balloc>:
{
    80003270:	711d                	addi	sp,sp,-96
    80003272:	ec86                	sd	ra,88(sp)
    80003274:	e8a2                	sd	s0,80(sp)
    80003276:	e4a6                	sd	s1,72(sp)
    80003278:	e0ca                	sd	s2,64(sp)
    8000327a:	fc4e                	sd	s3,56(sp)
    8000327c:	f852                	sd	s4,48(sp)
    8000327e:	f456                	sd	s5,40(sp)
    80003280:	f05a                	sd	s6,32(sp)
    80003282:	ec5e                	sd	s7,24(sp)
    80003284:	e862                	sd	s8,16(sp)
    80003286:	e466                	sd	s9,8(sp)
    80003288:	1080                	addi	s0,sp,96
  for(b = 0; b < sb.size; b += BPB){
    8000328a:	0001d797          	auipc	a5,0x1d
    8000328e:	bb678793          	addi	a5,a5,-1098 # 8001fe40 <sb>
    80003292:	43dc                	lw	a5,4(a5)
    80003294:	10078e63          	beqz	a5,800033b0 <balloc+0x140>
    80003298:	8baa                	mv	s7,a0
    8000329a:	4a81                	li	s5,0
    bp = bread(dev, BBLOCK(b, sb));
    8000329c:	0001db17          	auipc	s6,0x1d
    800032a0:	ba4b0b13          	addi	s6,s6,-1116 # 8001fe40 <sb>
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    800032a4:	4c05                	li	s8,1
      m = 1 << (bi % 8);
    800032a6:	4985                	li	s3,1
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    800032a8:	6a09                	lui	s4,0x2
  for(b = 0; b < sb.size; b += BPB){
    800032aa:	6c89                	lui	s9,0x2
    800032ac:	a079                	j	8000333a <balloc+0xca>
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    800032ae:	8942                	mv	s2,a6
      m = 1 << (bi % 8);
    800032b0:	4705                	li	a4,1
      if((bp->data[bi/8] & m) == 0){  // Is block free?
    800032b2:	4681                	li	a3,0
        bp->data[bi/8] |= m;  // Mark block in use.
    800032b4:	96a6                	add	a3,a3,s1
    800032b6:	8f51                	or	a4,a4,a2
    800032b8:	04e68c23          	sb	a4,88(a3)
        log_write(bp);
    800032bc:	8526                	mv	a0,s1
    800032be:	00001097          	auipc	ra,0x1
    800032c2:	0ba080e7          	jalr	186(ra) # 80004378 <log_write>
        brelse(bp);
    800032c6:	8526                	mv	a0,s1
    800032c8:	00000097          	auipc	ra,0x0
    800032cc:	e02080e7          	jalr	-510(ra) # 800030ca <brelse>
  bp = bread(dev, bno);
    800032d0:	85ca                	mv	a1,s2
    800032d2:	855e                	mv	a0,s7
    800032d4:	00000097          	auipc	ra,0x0
    800032d8:	cb4080e7          	jalr	-844(ra) # 80002f88 <bread>
    800032dc:	84aa                	mv	s1,a0
  memset(bp->data, 0, BSIZE);
    800032de:	40000613          	li	a2,1024
    800032e2:	4581                	li	a1,0
    800032e4:	05850513          	addi	a0,a0,88
    800032e8:	ffffe097          	auipc	ra,0xffffe
    800032ec:	a76080e7          	jalr	-1418(ra) # 80000d5e <memset>
  log_write(bp);
    800032f0:	8526                	mv	a0,s1
    800032f2:	00001097          	auipc	ra,0x1
    800032f6:	086080e7          	jalr	134(ra) # 80004378 <log_write>
  brelse(bp);
    800032fa:	8526                	mv	a0,s1
    800032fc:	00000097          	auipc	ra,0x0
    80003300:	dce080e7          	jalr	-562(ra) # 800030ca <brelse>
}
    80003304:	854a                	mv	a0,s2
    80003306:	60e6                	ld	ra,88(sp)
    80003308:	6446                	ld	s0,80(sp)
    8000330a:	64a6                	ld	s1,72(sp)
    8000330c:	6906                	ld	s2,64(sp)
    8000330e:	79e2                	ld	s3,56(sp)
    80003310:	7a42                	ld	s4,48(sp)
    80003312:	7aa2                	ld	s5,40(sp)
    80003314:	7b02                	ld	s6,32(sp)
    80003316:	6be2                	ld	s7,24(sp)
    80003318:	6c42                	ld	s8,16(sp)
    8000331a:	6ca2                	ld	s9,8(sp)
    8000331c:	6125                	addi	sp,sp,96
    8000331e:	8082                	ret
    brelse(bp);
    80003320:	8526                	mv	a0,s1
    80003322:	00000097          	auipc	ra,0x0
    80003326:	da8080e7          	jalr	-600(ra) # 800030ca <brelse>
  for(b = 0; b < sb.size; b += BPB){
    8000332a:	015c87bb          	addw	a5,s9,s5
    8000332e:	00078a9b          	sext.w	s5,a5
    80003332:	004b2703          	lw	a4,4(s6)
    80003336:	06eafd63          	bleu	a4,s5,800033b0 <balloc+0x140>
    bp = bread(dev, BBLOCK(b, sb));
    8000333a:	41fad79b          	sraiw	a5,s5,0x1f
    8000333e:	0137d79b          	srliw	a5,a5,0x13
    80003342:	015787bb          	addw	a5,a5,s5
    80003346:	40d7d79b          	sraiw	a5,a5,0xd
    8000334a:	01cb2583          	lw	a1,28(s6)
    8000334e:	9dbd                	addw	a1,a1,a5
    80003350:	855e                	mv	a0,s7
    80003352:	00000097          	auipc	ra,0x0
    80003356:	c36080e7          	jalr	-970(ra) # 80002f88 <bread>
    8000335a:	84aa                	mv	s1,a0
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    8000335c:	000a881b          	sext.w	a6,s5
    80003360:	004b2503          	lw	a0,4(s6)
    80003364:	faa87ee3          	bleu	a0,a6,80003320 <balloc+0xb0>
      if((bp->data[bi/8] & m) == 0){  // Is block free?
    80003368:	0584c603          	lbu	a2,88(s1)
    8000336c:	00167793          	andi	a5,a2,1
    80003370:	df9d                	beqz	a5,800032ae <balloc+0x3e>
    80003372:	4105053b          	subw	a0,a0,a6
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    80003376:	87e2                	mv	a5,s8
    80003378:	0107893b          	addw	s2,a5,a6
    8000337c:	faa782e3          	beq	a5,a0,80003320 <balloc+0xb0>
      m = 1 << (bi % 8);
    80003380:	41f7d71b          	sraiw	a4,a5,0x1f
    80003384:	01d7561b          	srliw	a2,a4,0x1d
    80003388:	00f606bb          	addw	a3,a2,a5
    8000338c:	0076f713          	andi	a4,a3,7
    80003390:	9f11                	subw	a4,a4,a2
    80003392:	00e9973b          	sllw	a4,s3,a4
      if((bp->data[bi/8] & m) == 0){  // Is block free?
    80003396:	4036d69b          	sraiw	a3,a3,0x3
    8000339a:	00d48633          	add	a2,s1,a3
    8000339e:	05864603          	lbu	a2,88(a2) # 1058 <_entry-0x7fffefa8>
    800033a2:	00c775b3          	and	a1,a4,a2
    800033a6:	d599                	beqz	a1,800032b4 <balloc+0x44>
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    800033a8:	2785                	addiw	a5,a5,1
    800033aa:	fd4797e3          	bne	a5,s4,80003378 <balloc+0x108>
    800033ae:	bf8d                	j	80003320 <balloc+0xb0>
  panic("balloc: out of blocks");
    800033b0:	00005517          	auipc	a0,0x5
    800033b4:	11050513          	addi	a0,a0,272 # 800084c0 <syscalls+0x128>
    800033b8:	ffffd097          	auipc	ra,0xffffd
    800033bc:	1bc080e7          	jalr	444(ra) # 80000574 <panic>

00000000800033c0 <bmap>:

// Return the disk block address of the nth block in inode ip.
// If there is no such block, bmap allocates one.
static uint
bmap(struct inode *ip, uint bn)
{
    800033c0:	7179                	addi	sp,sp,-48
    800033c2:	f406                	sd	ra,40(sp)
    800033c4:	f022                	sd	s0,32(sp)
    800033c6:	ec26                	sd	s1,24(sp)
    800033c8:	e84a                	sd	s2,16(sp)
    800033ca:	e44e                	sd	s3,8(sp)
    800033cc:	e052                	sd	s4,0(sp)
    800033ce:	1800                	addi	s0,sp,48
    800033d0:	89aa                	mv	s3,a0
  uint addr, *a;
  struct buf *bp;

  if(bn < NDIRECT){
    800033d2:	47ad                	li	a5,11
    800033d4:	04b7fe63          	bleu	a1,a5,80003430 <bmap+0x70>
    if((addr = ip->addrs[bn]) == 0)
      ip->addrs[bn] = addr = balloc(ip->dev);
    return addr;
  }
  bn -= NDIRECT;
    800033d8:	ff45849b          	addiw	s1,a1,-12
    800033dc:	0004871b          	sext.w	a4,s1

  if(bn < NINDIRECT){
    800033e0:	0ff00793          	li	a5,255
    800033e4:	0ae7e363          	bltu	a5,a4,8000348a <bmap+0xca>
    // Load indirect block, allocating if necessary.
    if((addr = ip->addrs[NDIRECT]) == 0)
    800033e8:	08052583          	lw	a1,128(a0)
    800033ec:	c5ad                	beqz	a1,80003456 <bmap+0x96>
      ip->addrs[NDIRECT] = addr = balloc(ip->dev);
    bp = bread(ip->dev, addr);
    800033ee:	0009a503          	lw	a0,0(s3)
    800033f2:	00000097          	auipc	ra,0x0
    800033f6:	b96080e7          	jalr	-1130(ra) # 80002f88 <bread>
    800033fa:	8a2a                	mv	s4,a0
    a = (uint*)bp->data;
    800033fc:	05850793          	addi	a5,a0,88
    if((addr = a[bn]) == 0){
    80003400:	02049593          	slli	a1,s1,0x20
    80003404:	9181                	srli	a1,a1,0x20
    80003406:	058a                	slli	a1,a1,0x2
    80003408:	00b784b3          	add	s1,a5,a1
    8000340c:	0004a903          	lw	s2,0(s1)
    80003410:	04090d63          	beqz	s2,8000346a <bmap+0xaa>
      a[bn] = addr = balloc(ip->dev);
      log_write(bp);
    }
    brelse(bp);
    80003414:	8552                	mv	a0,s4
    80003416:	00000097          	auipc	ra,0x0
    8000341a:	cb4080e7          	jalr	-844(ra) # 800030ca <brelse>
    return addr;
  }

  panic("bmap: out of range");
}
    8000341e:	854a                	mv	a0,s2
    80003420:	70a2                	ld	ra,40(sp)
    80003422:	7402                	ld	s0,32(sp)
    80003424:	64e2                	ld	s1,24(sp)
    80003426:	6942                	ld	s2,16(sp)
    80003428:	69a2                	ld	s3,8(sp)
    8000342a:	6a02                	ld	s4,0(sp)
    8000342c:	6145                	addi	sp,sp,48
    8000342e:	8082                	ret
    if((addr = ip->addrs[bn]) == 0)
    80003430:	02059493          	slli	s1,a1,0x20
    80003434:	9081                	srli	s1,s1,0x20
    80003436:	048a                	slli	s1,s1,0x2
    80003438:	94aa                	add	s1,s1,a0
    8000343a:	0504a903          	lw	s2,80(s1)
    8000343e:	fe0910e3          	bnez	s2,8000341e <bmap+0x5e>
      ip->addrs[bn] = addr = balloc(ip->dev);
    80003442:	4108                	lw	a0,0(a0)
    80003444:	00000097          	auipc	ra,0x0
    80003448:	e2c080e7          	jalr	-468(ra) # 80003270 <balloc>
    8000344c:	0005091b          	sext.w	s2,a0
    80003450:	0524a823          	sw	s2,80(s1)
    80003454:	b7e9                	j	8000341e <bmap+0x5e>
      ip->addrs[NDIRECT] = addr = balloc(ip->dev);
    80003456:	4108                	lw	a0,0(a0)
    80003458:	00000097          	auipc	ra,0x0
    8000345c:	e18080e7          	jalr	-488(ra) # 80003270 <balloc>
    80003460:	0005059b          	sext.w	a1,a0
    80003464:	08b9a023          	sw	a1,128(s3)
    80003468:	b759                	j	800033ee <bmap+0x2e>
      a[bn] = addr = balloc(ip->dev);
    8000346a:	0009a503          	lw	a0,0(s3)
    8000346e:	00000097          	auipc	ra,0x0
    80003472:	e02080e7          	jalr	-510(ra) # 80003270 <balloc>
    80003476:	0005091b          	sext.w	s2,a0
    8000347a:	0124a023          	sw	s2,0(s1)
      log_write(bp);
    8000347e:	8552                	mv	a0,s4
    80003480:	00001097          	auipc	ra,0x1
    80003484:	ef8080e7          	jalr	-264(ra) # 80004378 <log_write>
    80003488:	b771                	j	80003414 <bmap+0x54>
  panic("bmap: out of range");
    8000348a:	00005517          	auipc	a0,0x5
    8000348e:	04e50513          	addi	a0,a0,78 # 800084d8 <syscalls+0x140>
    80003492:	ffffd097          	auipc	ra,0xffffd
    80003496:	0e2080e7          	jalr	226(ra) # 80000574 <panic>

000000008000349a <iget>:
{
    8000349a:	7179                	addi	sp,sp,-48
    8000349c:	f406                	sd	ra,40(sp)
    8000349e:	f022                	sd	s0,32(sp)
    800034a0:	ec26                	sd	s1,24(sp)
    800034a2:	e84a                	sd	s2,16(sp)
    800034a4:	e44e                	sd	s3,8(sp)
    800034a6:	e052                	sd	s4,0(sp)
    800034a8:	1800                	addi	s0,sp,48
    800034aa:	89aa                	mv	s3,a0
    800034ac:	8a2e                	mv	s4,a1
  acquire(&icache.lock);
    800034ae:	0001d517          	auipc	a0,0x1d
    800034b2:	9b250513          	addi	a0,a0,-1614 # 8001fe60 <icache>
    800034b6:	ffffd097          	auipc	ra,0xffffd
    800034ba:	7ac080e7          	jalr	1964(ra) # 80000c62 <acquire>
  empty = 0;
    800034be:	4901                	li	s2,0
  for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){
    800034c0:	0001d497          	auipc	s1,0x1d
    800034c4:	9b848493          	addi	s1,s1,-1608 # 8001fe78 <icache+0x18>
    800034c8:	0001e697          	auipc	a3,0x1e
    800034cc:	44068693          	addi	a3,a3,1088 # 80021908 <log>
    800034d0:	a039                	j	800034de <iget+0x44>
    if(empty == 0 && ip->ref == 0)    // Remember empty slot.
    800034d2:	02090b63          	beqz	s2,80003508 <iget+0x6e>
  for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){
    800034d6:	08848493          	addi	s1,s1,136
    800034da:	02d48a63          	beq	s1,a3,8000350e <iget+0x74>
    if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){
    800034de:	449c                	lw	a5,8(s1)
    800034e0:	fef059e3          	blez	a5,800034d2 <iget+0x38>
    800034e4:	4098                	lw	a4,0(s1)
    800034e6:	ff3716e3          	bne	a4,s3,800034d2 <iget+0x38>
    800034ea:	40d8                	lw	a4,4(s1)
    800034ec:	ff4713e3          	bne	a4,s4,800034d2 <iget+0x38>
      ip->ref++;
    800034f0:	2785                	addiw	a5,a5,1
    800034f2:	c49c                	sw	a5,8(s1)
      release(&icache.lock);
    800034f4:	0001d517          	auipc	a0,0x1d
    800034f8:	96c50513          	addi	a0,a0,-1684 # 8001fe60 <icache>
    800034fc:	ffffe097          	auipc	ra,0xffffe
    80003500:	81a080e7          	jalr	-2022(ra) # 80000d16 <release>
      return ip;
    80003504:	8926                	mv	s2,s1
    80003506:	a03d                	j	80003534 <iget+0x9a>
    if(empty == 0 && ip->ref == 0)    // Remember empty slot.
    80003508:	f7f9                	bnez	a5,800034d6 <iget+0x3c>
    8000350a:	8926                	mv	s2,s1
    8000350c:	b7e9                	j	800034d6 <iget+0x3c>
  if(empty == 0)
    8000350e:	02090c63          	beqz	s2,80003546 <iget+0xac>
  ip->dev = dev;
    80003512:	01392023          	sw	s3,0(s2)
  ip->inum = inum;
    80003516:	01492223          	sw	s4,4(s2)
  ip->ref = 1;
    8000351a:	4785                	li	a5,1
    8000351c:	00f92423          	sw	a5,8(s2)
  ip->valid = 0;
    80003520:	04092023          	sw	zero,64(s2)
  release(&icache.lock);
    80003524:	0001d517          	auipc	a0,0x1d
    80003528:	93c50513          	addi	a0,a0,-1732 # 8001fe60 <icache>
    8000352c:	ffffd097          	auipc	ra,0xffffd
    80003530:	7ea080e7          	jalr	2026(ra) # 80000d16 <release>
}
    80003534:	854a                	mv	a0,s2
    80003536:	70a2                	ld	ra,40(sp)
    80003538:	7402                	ld	s0,32(sp)
    8000353a:	64e2                	ld	s1,24(sp)
    8000353c:	6942                	ld	s2,16(sp)
    8000353e:	69a2                	ld	s3,8(sp)
    80003540:	6a02                	ld	s4,0(sp)
    80003542:	6145                	addi	sp,sp,48
    80003544:	8082                	ret
    panic("iget: no inodes");
    80003546:	00005517          	auipc	a0,0x5
    8000354a:	faa50513          	addi	a0,a0,-86 # 800084f0 <syscalls+0x158>
    8000354e:	ffffd097          	auipc	ra,0xffffd
    80003552:	026080e7          	jalr	38(ra) # 80000574 <panic>

0000000080003556 <fsinit>:
fsinit(int dev) {
    80003556:	7179                	addi	sp,sp,-48
    80003558:	f406                	sd	ra,40(sp)
    8000355a:	f022                	sd	s0,32(sp)
    8000355c:	ec26                	sd	s1,24(sp)
    8000355e:	e84a                	sd	s2,16(sp)
    80003560:	e44e                	sd	s3,8(sp)
    80003562:	1800                	addi	s0,sp,48
    80003564:	89aa                	mv	s3,a0
  bp = bread(dev, 1);
    80003566:	4585                	li	a1,1
    80003568:	00000097          	auipc	ra,0x0
    8000356c:	a20080e7          	jalr	-1504(ra) # 80002f88 <bread>
    80003570:	892a                	mv	s2,a0
  memmove(sb, bp->data, sizeof(*sb));
    80003572:	0001d497          	auipc	s1,0x1d
    80003576:	8ce48493          	addi	s1,s1,-1842 # 8001fe40 <sb>
    8000357a:	02000613          	li	a2,32
    8000357e:	05850593          	addi	a1,a0,88
    80003582:	8526                	mv	a0,s1
    80003584:	ffffe097          	auipc	ra,0xffffe
    80003588:	846080e7          	jalr	-1978(ra) # 80000dca <memmove>
  brelse(bp);
    8000358c:	854a                	mv	a0,s2
    8000358e:	00000097          	auipc	ra,0x0
    80003592:	b3c080e7          	jalr	-1220(ra) # 800030ca <brelse>
  if(sb.magic != FSMAGIC)
    80003596:	4098                	lw	a4,0(s1)
    80003598:	102037b7          	lui	a5,0x10203
    8000359c:	04078793          	addi	a5,a5,64 # 10203040 <_entry-0x6fdfcfc0>
    800035a0:	02f71263          	bne	a4,a5,800035c4 <fsinit+0x6e>
  initlog(dev, &sb);
    800035a4:	0001d597          	auipc	a1,0x1d
    800035a8:	89c58593          	addi	a1,a1,-1892 # 8001fe40 <sb>
    800035ac:	854e                	mv	a0,s3
    800035ae:	00001097          	auipc	ra,0x1
    800035b2:	b4c080e7          	jalr	-1204(ra) # 800040fa <initlog>
}
    800035b6:	70a2                	ld	ra,40(sp)
    800035b8:	7402                	ld	s0,32(sp)
    800035ba:	64e2                	ld	s1,24(sp)
    800035bc:	6942                	ld	s2,16(sp)
    800035be:	69a2                	ld	s3,8(sp)
    800035c0:	6145                	addi	sp,sp,48
    800035c2:	8082                	ret
    panic("invalid file system");
    800035c4:	00005517          	auipc	a0,0x5
    800035c8:	f3c50513          	addi	a0,a0,-196 # 80008500 <syscalls+0x168>
    800035cc:	ffffd097          	auipc	ra,0xffffd
    800035d0:	fa8080e7          	jalr	-88(ra) # 80000574 <panic>

00000000800035d4 <iinit>:
{
    800035d4:	7179                	addi	sp,sp,-48
    800035d6:	f406                	sd	ra,40(sp)
    800035d8:	f022                	sd	s0,32(sp)
    800035da:	ec26                	sd	s1,24(sp)
    800035dc:	e84a                	sd	s2,16(sp)
    800035de:	e44e                	sd	s3,8(sp)
    800035e0:	1800                	addi	s0,sp,48
  initlock(&icache.lock, "icache");
    800035e2:	00005597          	auipc	a1,0x5
    800035e6:	f3658593          	addi	a1,a1,-202 # 80008518 <syscalls+0x180>
    800035ea:	0001d517          	auipc	a0,0x1d
    800035ee:	87650513          	addi	a0,a0,-1930 # 8001fe60 <icache>
    800035f2:	ffffd097          	auipc	ra,0xffffd
    800035f6:	5e0080e7          	jalr	1504(ra) # 80000bd2 <initlock>
  for(i = 0; i < NINODE; i++) {
    800035fa:	0001d497          	auipc	s1,0x1d
    800035fe:	88e48493          	addi	s1,s1,-1906 # 8001fe88 <icache+0x28>
    80003602:	0001e997          	auipc	s3,0x1e
    80003606:	31698993          	addi	s3,s3,790 # 80021918 <log+0x10>
    initsleeplock(&icache.inode[i].lock, "inode");
    8000360a:	00005917          	auipc	s2,0x5
    8000360e:	f1690913          	addi	s2,s2,-234 # 80008520 <syscalls+0x188>
    80003612:	85ca                	mv	a1,s2
    80003614:	8526                	mv	a0,s1
    80003616:	00001097          	auipc	ra,0x1
    8000361a:	e66080e7          	jalr	-410(ra) # 8000447c <initsleeplock>
  for(i = 0; i < NINODE; i++) {
    8000361e:	08848493          	addi	s1,s1,136
    80003622:	ff3498e3          	bne	s1,s3,80003612 <iinit+0x3e>
}
    80003626:	70a2                	ld	ra,40(sp)
    80003628:	7402                	ld	s0,32(sp)
    8000362a:	64e2                	ld	s1,24(sp)
    8000362c:	6942                	ld	s2,16(sp)
    8000362e:	69a2                	ld	s3,8(sp)
    80003630:	6145                	addi	sp,sp,48
    80003632:	8082                	ret

0000000080003634 <ialloc>:
{
    80003634:	715d                	addi	sp,sp,-80
    80003636:	e486                	sd	ra,72(sp)
    80003638:	e0a2                	sd	s0,64(sp)
    8000363a:	fc26                	sd	s1,56(sp)
    8000363c:	f84a                	sd	s2,48(sp)
    8000363e:	f44e                	sd	s3,40(sp)
    80003640:	f052                	sd	s4,32(sp)
    80003642:	ec56                	sd	s5,24(sp)
    80003644:	e85a                	sd	s6,16(sp)
    80003646:	e45e                	sd	s7,8(sp)
    80003648:	0880                	addi	s0,sp,80
  for(inum = 1; inum < sb.ninodes; inum++){
    8000364a:	0001c797          	auipc	a5,0x1c
    8000364e:	7f678793          	addi	a5,a5,2038 # 8001fe40 <sb>
    80003652:	47d8                	lw	a4,12(a5)
    80003654:	4785                	li	a5,1
    80003656:	04e7fa63          	bleu	a4,a5,800036aa <ialloc+0x76>
    8000365a:	8a2a                	mv	s4,a0
    8000365c:	8b2e                	mv	s6,a1
    8000365e:	4485                	li	s1,1
    bp = bread(dev, IBLOCK(inum, sb));
    80003660:	0001c997          	auipc	s3,0x1c
    80003664:	7e098993          	addi	s3,s3,2016 # 8001fe40 <sb>
    80003668:	00048a9b          	sext.w	s5,s1
    8000366c:	0044d593          	srli	a1,s1,0x4
    80003670:	0189a783          	lw	a5,24(s3)
    80003674:	9dbd                	addw	a1,a1,a5
    80003676:	8552                	mv	a0,s4
    80003678:	00000097          	auipc	ra,0x0
    8000367c:	910080e7          	jalr	-1776(ra) # 80002f88 <bread>
    80003680:	8baa                	mv	s7,a0
    dip = (struct dinode*)bp->data + inum%IPB;
    80003682:	05850913          	addi	s2,a0,88
    80003686:	00f4f793          	andi	a5,s1,15
    8000368a:	079a                	slli	a5,a5,0x6
    8000368c:	993e                	add	s2,s2,a5
    if(dip->type == 0){  // a free inode
    8000368e:	00091783          	lh	a5,0(s2)
    80003692:	c785                	beqz	a5,800036ba <ialloc+0x86>
    brelse(bp);
    80003694:	00000097          	auipc	ra,0x0
    80003698:	a36080e7          	jalr	-1482(ra) # 800030ca <brelse>
  for(inum = 1; inum < sb.ninodes; inum++){
    8000369c:	0485                	addi	s1,s1,1
    8000369e:	00c9a703          	lw	a4,12(s3)
    800036a2:	0004879b          	sext.w	a5,s1
    800036a6:	fce7e1e3          	bltu	a5,a4,80003668 <ialloc+0x34>
  panic("ialloc: no inodes");
    800036aa:	00005517          	auipc	a0,0x5
    800036ae:	e7e50513          	addi	a0,a0,-386 # 80008528 <syscalls+0x190>
    800036b2:	ffffd097          	auipc	ra,0xffffd
    800036b6:	ec2080e7          	jalr	-318(ra) # 80000574 <panic>
      memset(dip, 0, sizeof(*dip));
    800036ba:	04000613          	li	a2,64
    800036be:	4581                	li	a1,0
    800036c0:	854a                	mv	a0,s2
    800036c2:	ffffd097          	auipc	ra,0xffffd
    800036c6:	69c080e7          	jalr	1692(ra) # 80000d5e <memset>
      dip->type = type;
    800036ca:	01691023          	sh	s6,0(s2)
      log_write(bp);   // mark it allocated on the disk
    800036ce:	855e                	mv	a0,s7
    800036d0:	00001097          	auipc	ra,0x1
    800036d4:	ca8080e7          	jalr	-856(ra) # 80004378 <log_write>
      brelse(bp);
    800036d8:	855e                	mv	a0,s7
    800036da:	00000097          	auipc	ra,0x0
    800036de:	9f0080e7          	jalr	-1552(ra) # 800030ca <brelse>
      return iget(dev, inum);
    800036e2:	85d6                	mv	a1,s5
    800036e4:	8552                	mv	a0,s4
    800036e6:	00000097          	auipc	ra,0x0
    800036ea:	db4080e7          	jalr	-588(ra) # 8000349a <iget>
}
    800036ee:	60a6                	ld	ra,72(sp)
    800036f0:	6406                	ld	s0,64(sp)
    800036f2:	74e2                	ld	s1,56(sp)
    800036f4:	7942                	ld	s2,48(sp)
    800036f6:	79a2                	ld	s3,40(sp)
    800036f8:	7a02                	ld	s4,32(sp)
    800036fa:	6ae2                	ld	s5,24(sp)
    800036fc:	6b42                	ld	s6,16(sp)
    800036fe:	6ba2                	ld	s7,8(sp)
    80003700:	6161                	addi	sp,sp,80
    80003702:	8082                	ret

0000000080003704 <iupdate>:
{
    80003704:	1101                	addi	sp,sp,-32
    80003706:	ec06                	sd	ra,24(sp)
    80003708:	e822                	sd	s0,16(sp)
    8000370a:	e426                	sd	s1,8(sp)
    8000370c:	e04a                	sd	s2,0(sp)
    8000370e:	1000                	addi	s0,sp,32
    80003710:	84aa                	mv	s1,a0
  bp = bread(ip->dev, IBLOCK(ip->inum, sb));
    80003712:	415c                	lw	a5,4(a0)
    80003714:	0047d79b          	srliw	a5,a5,0x4
    80003718:	0001c717          	auipc	a4,0x1c
    8000371c:	72870713          	addi	a4,a4,1832 # 8001fe40 <sb>
    80003720:	4f0c                	lw	a1,24(a4)
    80003722:	9dbd                	addw	a1,a1,a5
    80003724:	4108                	lw	a0,0(a0)
    80003726:	00000097          	auipc	ra,0x0
    8000372a:	862080e7          	jalr	-1950(ra) # 80002f88 <bread>
    8000372e:	892a                	mv	s2,a0
  dip = (struct dinode*)bp->data + ip->inum%IPB;
    80003730:	05850513          	addi	a0,a0,88
    80003734:	40dc                	lw	a5,4(s1)
    80003736:	8bbd                	andi	a5,a5,15
    80003738:	079a                	slli	a5,a5,0x6
    8000373a:	953e                	add	a0,a0,a5
  dip->type = ip->type;
    8000373c:	04449783          	lh	a5,68(s1)
    80003740:	00f51023          	sh	a5,0(a0)
  dip->major = ip->major;
    80003744:	04649783          	lh	a5,70(s1)
    80003748:	00f51123          	sh	a5,2(a0)
  dip->minor = ip->minor;
    8000374c:	04849783          	lh	a5,72(s1)
    80003750:	00f51223          	sh	a5,4(a0)
  dip->nlink = ip->nlink;
    80003754:	04a49783          	lh	a5,74(s1)
    80003758:	00f51323          	sh	a5,6(a0)
  dip->size = ip->size;
    8000375c:	44fc                	lw	a5,76(s1)
    8000375e:	c51c                	sw	a5,8(a0)
  memmove(dip->addrs, ip->addrs, sizeof(ip->addrs));
    80003760:	03400613          	li	a2,52
    80003764:	05048593          	addi	a1,s1,80
    80003768:	0531                	addi	a0,a0,12
    8000376a:	ffffd097          	auipc	ra,0xffffd
    8000376e:	660080e7          	jalr	1632(ra) # 80000dca <memmove>
  log_write(bp);
    80003772:	854a                	mv	a0,s2
    80003774:	00001097          	auipc	ra,0x1
    80003778:	c04080e7          	jalr	-1020(ra) # 80004378 <log_write>
  brelse(bp);
    8000377c:	854a                	mv	a0,s2
    8000377e:	00000097          	auipc	ra,0x0
    80003782:	94c080e7          	jalr	-1716(ra) # 800030ca <brelse>
}
    80003786:	60e2                	ld	ra,24(sp)
    80003788:	6442                	ld	s0,16(sp)
    8000378a:	64a2                	ld	s1,8(sp)
    8000378c:	6902                	ld	s2,0(sp)
    8000378e:	6105                	addi	sp,sp,32
    80003790:	8082                	ret

0000000080003792 <idup>:
{
    80003792:	1101                	addi	sp,sp,-32
    80003794:	ec06                	sd	ra,24(sp)
    80003796:	e822                	sd	s0,16(sp)
    80003798:	e426                	sd	s1,8(sp)
    8000379a:	1000                	addi	s0,sp,32
    8000379c:	84aa                	mv	s1,a0
  acquire(&icache.lock);
    8000379e:	0001c517          	auipc	a0,0x1c
    800037a2:	6c250513          	addi	a0,a0,1730 # 8001fe60 <icache>
    800037a6:	ffffd097          	auipc	ra,0xffffd
    800037aa:	4bc080e7          	jalr	1212(ra) # 80000c62 <acquire>
  ip->ref++;
    800037ae:	449c                	lw	a5,8(s1)
    800037b0:	2785                	addiw	a5,a5,1
    800037b2:	c49c                	sw	a5,8(s1)
  release(&icache.lock);
    800037b4:	0001c517          	auipc	a0,0x1c
    800037b8:	6ac50513          	addi	a0,a0,1708 # 8001fe60 <icache>
    800037bc:	ffffd097          	auipc	ra,0xffffd
    800037c0:	55a080e7          	jalr	1370(ra) # 80000d16 <release>
}
    800037c4:	8526                	mv	a0,s1
    800037c6:	60e2                	ld	ra,24(sp)
    800037c8:	6442                	ld	s0,16(sp)
    800037ca:	64a2                	ld	s1,8(sp)
    800037cc:	6105                	addi	sp,sp,32
    800037ce:	8082                	ret

00000000800037d0 <ilock>:
{
    800037d0:	1101                	addi	sp,sp,-32
    800037d2:	ec06                	sd	ra,24(sp)
    800037d4:	e822                	sd	s0,16(sp)
    800037d6:	e426                	sd	s1,8(sp)
    800037d8:	e04a                	sd	s2,0(sp)
    800037da:	1000                	addi	s0,sp,32
  if(ip == 0 || ip->ref < 1)
    800037dc:	c115                	beqz	a0,80003800 <ilock+0x30>
    800037de:	84aa                	mv	s1,a0
    800037e0:	451c                	lw	a5,8(a0)
    800037e2:	00f05f63          	blez	a5,80003800 <ilock+0x30>
  acquiresleep(&ip->lock);
    800037e6:	0541                	addi	a0,a0,16
    800037e8:	00001097          	auipc	ra,0x1
    800037ec:	cce080e7          	jalr	-818(ra) # 800044b6 <acquiresleep>
  if(ip->valid == 0){
    800037f0:	40bc                	lw	a5,64(s1)
    800037f2:	cf99                	beqz	a5,80003810 <ilock+0x40>
}
    800037f4:	60e2                	ld	ra,24(sp)
    800037f6:	6442                	ld	s0,16(sp)
    800037f8:	64a2                	ld	s1,8(sp)
    800037fa:	6902                	ld	s2,0(sp)
    800037fc:	6105                	addi	sp,sp,32
    800037fe:	8082                	ret
    panic("ilock");
    80003800:	00005517          	auipc	a0,0x5
    80003804:	d4050513          	addi	a0,a0,-704 # 80008540 <syscalls+0x1a8>
    80003808:	ffffd097          	auipc	ra,0xffffd
    8000380c:	d6c080e7          	jalr	-660(ra) # 80000574 <panic>
    bp = bread(ip->dev, IBLOCK(ip->inum, sb));
    80003810:	40dc                	lw	a5,4(s1)
    80003812:	0047d79b          	srliw	a5,a5,0x4
    80003816:	0001c717          	auipc	a4,0x1c
    8000381a:	62a70713          	addi	a4,a4,1578 # 8001fe40 <sb>
    8000381e:	4f0c                	lw	a1,24(a4)
    80003820:	9dbd                	addw	a1,a1,a5
    80003822:	4088                	lw	a0,0(s1)
    80003824:	fffff097          	auipc	ra,0xfffff
    80003828:	764080e7          	jalr	1892(ra) # 80002f88 <bread>
    8000382c:	892a                	mv	s2,a0
    dip = (struct dinode*)bp->data + ip->inum%IPB;
    8000382e:	05850593          	addi	a1,a0,88
    80003832:	40dc                	lw	a5,4(s1)
    80003834:	8bbd                	andi	a5,a5,15
    80003836:	079a                	slli	a5,a5,0x6
    80003838:	95be                	add	a1,a1,a5
    ip->type = dip->type;
    8000383a:	00059783          	lh	a5,0(a1)
    8000383e:	04f49223          	sh	a5,68(s1)
    ip->major = dip->major;
    80003842:	00259783          	lh	a5,2(a1)
    80003846:	04f49323          	sh	a5,70(s1)
    ip->minor = dip->minor;
    8000384a:	00459783          	lh	a5,4(a1)
    8000384e:	04f49423          	sh	a5,72(s1)
    ip->nlink = dip->nlink;
    80003852:	00659783          	lh	a5,6(a1)
    80003856:	04f49523          	sh	a5,74(s1)
    ip->size = dip->size;
    8000385a:	459c                	lw	a5,8(a1)
    8000385c:	c4fc                	sw	a5,76(s1)
    memmove(ip->addrs, dip->addrs, sizeof(ip->addrs));
    8000385e:	03400613          	li	a2,52
    80003862:	05b1                	addi	a1,a1,12
    80003864:	05048513          	addi	a0,s1,80
    80003868:	ffffd097          	auipc	ra,0xffffd
    8000386c:	562080e7          	jalr	1378(ra) # 80000dca <memmove>
    brelse(bp);
    80003870:	854a                	mv	a0,s2
    80003872:	00000097          	auipc	ra,0x0
    80003876:	858080e7          	jalr	-1960(ra) # 800030ca <brelse>
    ip->valid = 1;
    8000387a:	4785                	li	a5,1
    8000387c:	c0bc                	sw	a5,64(s1)
    if(ip->type == 0)
    8000387e:	04449783          	lh	a5,68(s1)
    80003882:	fbad                	bnez	a5,800037f4 <ilock+0x24>
      panic("ilock: no type");
    80003884:	00005517          	auipc	a0,0x5
    80003888:	cc450513          	addi	a0,a0,-828 # 80008548 <syscalls+0x1b0>
    8000388c:	ffffd097          	auipc	ra,0xffffd
    80003890:	ce8080e7          	jalr	-792(ra) # 80000574 <panic>

0000000080003894 <iunlock>:
{
    80003894:	1101                	addi	sp,sp,-32
    80003896:	ec06                	sd	ra,24(sp)
    80003898:	e822                	sd	s0,16(sp)
    8000389a:	e426                	sd	s1,8(sp)
    8000389c:	e04a                	sd	s2,0(sp)
    8000389e:	1000                	addi	s0,sp,32
  if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1)
    800038a0:	c905                	beqz	a0,800038d0 <iunlock+0x3c>
    800038a2:	84aa                	mv	s1,a0
    800038a4:	01050913          	addi	s2,a0,16
    800038a8:	854a                	mv	a0,s2
    800038aa:	00001097          	auipc	ra,0x1
    800038ae:	ca6080e7          	jalr	-858(ra) # 80004550 <holdingsleep>
    800038b2:	cd19                	beqz	a0,800038d0 <iunlock+0x3c>
    800038b4:	449c                	lw	a5,8(s1)
    800038b6:	00f05d63          	blez	a5,800038d0 <iunlock+0x3c>
  releasesleep(&ip->lock);
    800038ba:	854a                	mv	a0,s2
    800038bc:	00001097          	auipc	ra,0x1
    800038c0:	c50080e7          	jalr	-944(ra) # 8000450c <releasesleep>
}
    800038c4:	60e2                	ld	ra,24(sp)
    800038c6:	6442                	ld	s0,16(sp)
    800038c8:	64a2                	ld	s1,8(sp)
    800038ca:	6902                	ld	s2,0(sp)
    800038cc:	6105                	addi	sp,sp,32
    800038ce:	8082                	ret
    panic("iunlock");
    800038d0:	00005517          	auipc	a0,0x5
    800038d4:	c8850513          	addi	a0,a0,-888 # 80008558 <syscalls+0x1c0>
    800038d8:	ffffd097          	auipc	ra,0xffffd
    800038dc:	c9c080e7          	jalr	-868(ra) # 80000574 <panic>

00000000800038e0 <itrunc>:

// Truncate inode (discard contents).
// Caller must hold ip->lock.
void
itrunc(struct inode *ip)
{
    800038e0:	7179                	addi	sp,sp,-48
    800038e2:	f406                	sd	ra,40(sp)
    800038e4:	f022                	sd	s0,32(sp)
    800038e6:	ec26                	sd	s1,24(sp)
    800038e8:	e84a                	sd	s2,16(sp)
    800038ea:	e44e                	sd	s3,8(sp)
    800038ec:	e052                	sd	s4,0(sp)
    800038ee:	1800                	addi	s0,sp,48
    800038f0:	89aa                	mv	s3,a0
  int i, j;
  struct buf *bp;
  uint *a;

  for(i = 0; i < NDIRECT; i++){
    800038f2:	05050493          	addi	s1,a0,80
    800038f6:	08050913          	addi	s2,a0,128
    800038fa:	a821                	j	80003912 <itrunc+0x32>
    if(ip->addrs[i]){
      bfree(ip->dev, ip->addrs[i]);
    800038fc:	0009a503          	lw	a0,0(s3)
    80003900:	00000097          	auipc	ra,0x0
    80003904:	8e0080e7          	jalr	-1824(ra) # 800031e0 <bfree>
      ip->addrs[i] = 0;
    80003908:	0004a023          	sw	zero,0(s1)
  for(i = 0; i < NDIRECT; i++){
    8000390c:	0491                	addi	s1,s1,4
    8000390e:	01248563          	beq	s1,s2,80003918 <itrunc+0x38>
    if(ip->addrs[i]){
    80003912:	408c                	lw	a1,0(s1)
    80003914:	dde5                	beqz	a1,8000390c <itrunc+0x2c>
    80003916:	b7dd                	j	800038fc <itrunc+0x1c>
    }
  }

  if(ip->addrs[NDIRECT]){
    80003918:	0809a583          	lw	a1,128(s3)
    8000391c:	e185                	bnez	a1,8000393c <itrunc+0x5c>
    brelse(bp);
    bfree(ip->dev, ip->addrs[NDIRECT]);
    ip->addrs[NDIRECT] = 0;
  }

  ip->size = 0;
    8000391e:	0409a623          	sw	zero,76(s3)
  iupdate(ip);
    80003922:	854e                	mv	a0,s3
    80003924:	00000097          	auipc	ra,0x0
    80003928:	de0080e7          	jalr	-544(ra) # 80003704 <iupdate>
}
    8000392c:	70a2                	ld	ra,40(sp)
    8000392e:	7402                	ld	s0,32(sp)
    80003930:	64e2                	ld	s1,24(sp)
    80003932:	6942                	ld	s2,16(sp)
    80003934:	69a2                	ld	s3,8(sp)
    80003936:	6a02                	ld	s4,0(sp)
    80003938:	6145                	addi	sp,sp,48
    8000393a:	8082                	ret
    bp = bread(ip->dev, ip->addrs[NDIRECT]);
    8000393c:	0009a503          	lw	a0,0(s3)
    80003940:	fffff097          	auipc	ra,0xfffff
    80003944:	648080e7          	jalr	1608(ra) # 80002f88 <bread>
    80003948:	8a2a                	mv	s4,a0
    for(j = 0; j < NINDIRECT; j++){
    8000394a:	05850493          	addi	s1,a0,88
    8000394e:	45850913          	addi	s2,a0,1112
    80003952:	a811                	j	80003966 <itrunc+0x86>
        bfree(ip->dev, a[j]);
    80003954:	0009a503          	lw	a0,0(s3)
    80003958:	00000097          	auipc	ra,0x0
    8000395c:	888080e7          	jalr	-1912(ra) # 800031e0 <bfree>
    for(j = 0; j < NINDIRECT; j++){
    80003960:	0491                	addi	s1,s1,4
    80003962:	01248563          	beq	s1,s2,8000396c <itrunc+0x8c>
      if(a[j])
    80003966:	408c                	lw	a1,0(s1)
    80003968:	dde5                	beqz	a1,80003960 <itrunc+0x80>
    8000396a:	b7ed                	j	80003954 <itrunc+0x74>
    brelse(bp);
    8000396c:	8552                	mv	a0,s4
    8000396e:	fffff097          	auipc	ra,0xfffff
    80003972:	75c080e7          	jalr	1884(ra) # 800030ca <brelse>
    bfree(ip->dev, ip->addrs[NDIRECT]);
    80003976:	0809a583          	lw	a1,128(s3)
    8000397a:	0009a503          	lw	a0,0(s3)
    8000397e:	00000097          	auipc	ra,0x0
    80003982:	862080e7          	jalr	-1950(ra) # 800031e0 <bfree>
    ip->addrs[NDIRECT] = 0;
    80003986:	0809a023          	sw	zero,128(s3)
    8000398a:	bf51                	j	8000391e <itrunc+0x3e>

000000008000398c <iput>:
{
    8000398c:	1101                	addi	sp,sp,-32
    8000398e:	ec06                	sd	ra,24(sp)
    80003990:	e822                	sd	s0,16(sp)
    80003992:	e426                	sd	s1,8(sp)
    80003994:	e04a                	sd	s2,0(sp)
    80003996:	1000                	addi	s0,sp,32
    80003998:	84aa                	mv	s1,a0
  acquire(&icache.lock);
    8000399a:	0001c517          	auipc	a0,0x1c
    8000399e:	4c650513          	addi	a0,a0,1222 # 8001fe60 <icache>
    800039a2:	ffffd097          	auipc	ra,0xffffd
    800039a6:	2c0080e7          	jalr	704(ra) # 80000c62 <acquire>
  if(ip->ref == 1 && ip->valid && ip->nlink == 0){
    800039aa:	4498                	lw	a4,8(s1)
    800039ac:	4785                	li	a5,1
    800039ae:	02f70363          	beq	a4,a5,800039d4 <iput+0x48>
  ip->ref--;
    800039b2:	449c                	lw	a5,8(s1)
    800039b4:	37fd                	addiw	a5,a5,-1
    800039b6:	c49c                	sw	a5,8(s1)
  release(&icache.lock);
    800039b8:	0001c517          	auipc	a0,0x1c
    800039bc:	4a850513          	addi	a0,a0,1192 # 8001fe60 <icache>
    800039c0:	ffffd097          	auipc	ra,0xffffd
    800039c4:	356080e7          	jalr	854(ra) # 80000d16 <release>
}
    800039c8:	60e2                	ld	ra,24(sp)
    800039ca:	6442                	ld	s0,16(sp)
    800039cc:	64a2                	ld	s1,8(sp)
    800039ce:	6902                	ld	s2,0(sp)
    800039d0:	6105                	addi	sp,sp,32
    800039d2:	8082                	ret
  if(ip->ref == 1 && ip->valid && ip->nlink == 0){
    800039d4:	40bc                	lw	a5,64(s1)
    800039d6:	dff1                	beqz	a5,800039b2 <iput+0x26>
    800039d8:	04a49783          	lh	a5,74(s1)
    800039dc:	fbf9                	bnez	a5,800039b2 <iput+0x26>
    acquiresleep(&ip->lock);
    800039de:	01048913          	addi	s2,s1,16
    800039e2:	854a                	mv	a0,s2
    800039e4:	00001097          	auipc	ra,0x1
    800039e8:	ad2080e7          	jalr	-1326(ra) # 800044b6 <acquiresleep>
    release(&icache.lock);
    800039ec:	0001c517          	auipc	a0,0x1c
    800039f0:	47450513          	addi	a0,a0,1140 # 8001fe60 <icache>
    800039f4:	ffffd097          	auipc	ra,0xffffd
    800039f8:	322080e7          	jalr	802(ra) # 80000d16 <release>
    itrunc(ip);
    800039fc:	8526                	mv	a0,s1
    800039fe:	00000097          	auipc	ra,0x0
    80003a02:	ee2080e7          	jalr	-286(ra) # 800038e0 <itrunc>
    ip->type = 0;
    80003a06:	04049223          	sh	zero,68(s1)
    iupdate(ip);
    80003a0a:	8526                	mv	a0,s1
    80003a0c:	00000097          	auipc	ra,0x0
    80003a10:	cf8080e7          	jalr	-776(ra) # 80003704 <iupdate>
    ip->valid = 0;
    80003a14:	0404a023          	sw	zero,64(s1)
    releasesleep(&ip->lock);
    80003a18:	854a                	mv	a0,s2
    80003a1a:	00001097          	auipc	ra,0x1
    80003a1e:	af2080e7          	jalr	-1294(ra) # 8000450c <releasesleep>
    acquire(&icache.lock);
    80003a22:	0001c517          	auipc	a0,0x1c
    80003a26:	43e50513          	addi	a0,a0,1086 # 8001fe60 <icache>
    80003a2a:	ffffd097          	auipc	ra,0xffffd
    80003a2e:	238080e7          	jalr	568(ra) # 80000c62 <acquire>
    80003a32:	b741                	j	800039b2 <iput+0x26>

0000000080003a34 <iunlockput>:
{
    80003a34:	1101                	addi	sp,sp,-32
    80003a36:	ec06                	sd	ra,24(sp)
    80003a38:	e822                	sd	s0,16(sp)
    80003a3a:	e426                	sd	s1,8(sp)
    80003a3c:	1000                	addi	s0,sp,32
    80003a3e:	84aa                	mv	s1,a0
  iunlock(ip);
    80003a40:	00000097          	auipc	ra,0x0
    80003a44:	e54080e7          	jalr	-428(ra) # 80003894 <iunlock>
  iput(ip);
    80003a48:	8526                	mv	a0,s1
    80003a4a:	00000097          	auipc	ra,0x0
    80003a4e:	f42080e7          	jalr	-190(ra) # 8000398c <iput>
}
    80003a52:	60e2                	ld	ra,24(sp)
    80003a54:	6442                	ld	s0,16(sp)
    80003a56:	64a2                	ld	s1,8(sp)
    80003a58:	6105                	addi	sp,sp,32
    80003a5a:	8082                	ret

0000000080003a5c <stati>:

// Copy stat information from inode.
// Caller must hold ip->lock.
void
stati(struct inode *ip, struct stat *st)
{
    80003a5c:	1141                	addi	sp,sp,-16
    80003a5e:	e422                	sd	s0,8(sp)
    80003a60:	0800                	addi	s0,sp,16
  st->dev = ip->dev;
    80003a62:	411c                	lw	a5,0(a0)
    80003a64:	c19c                	sw	a5,0(a1)
  st->ino = ip->inum;
    80003a66:	415c                	lw	a5,4(a0)
    80003a68:	c1dc                	sw	a5,4(a1)
  st->type = ip->type;
    80003a6a:	04451783          	lh	a5,68(a0)
    80003a6e:	00f59423          	sh	a5,8(a1)
  st->nlink = ip->nlink;
    80003a72:	04a51783          	lh	a5,74(a0)
    80003a76:	00f59523          	sh	a5,10(a1)
  st->size = ip->size;
    80003a7a:	04c56783          	lwu	a5,76(a0)
    80003a7e:	e99c                	sd	a5,16(a1)
}
    80003a80:	6422                	ld	s0,8(sp)
    80003a82:	0141                	addi	sp,sp,16
    80003a84:	8082                	ret

0000000080003a86 <readi>:
readi(struct inode *ip, int user_dst, uint64 dst, uint off, uint n)
{
  uint tot, m;
  struct buf *bp;

  if(off > ip->size || off + n < off)
    80003a86:	457c                	lw	a5,76(a0)
    80003a88:	0ed7e963          	bltu	a5,a3,80003b7a <readi+0xf4>
{
    80003a8c:	7159                	addi	sp,sp,-112
    80003a8e:	f486                	sd	ra,104(sp)
    80003a90:	f0a2                	sd	s0,96(sp)
    80003a92:	eca6                	sd	s1,88(sp)
    80003a94:	e8ca                	sd	s2,80(sp)
    80003a96:	e4ce                	sd	s3,72(sp)
    80003a98:	e0d2                	sd	s4,64(sp)
    80003a9a:	fc56                	sd	s5,56(sp)
    80003a9c:	f85a                	sd	s6,48(sp)
    80003a9e:	f45e                	sd	s7,40(sp)
    80003aa0:	f062                	sd	s8,32(sp)
    80003aa2:	ec66                	sd	s9,24(sp)
    80003aa4:	e86a                	sd	s10,16(sp)
    80003aa6:	e46e                	sd	s11,8(sp)
    80003aa8:	1880                	addi	s0,sp,112
    80003aaa:	8baa                	mv	s7,a0
    80003aac:	8c2e                	mv	s8,a1
    80003aae:	8a32                	mv	s4,a2
    80003ab0:	84b6                	mv	s1,a3
    80003ab2:	8b3a                	mv	s6,a4
  if(off > ip->size || off + n < off)
    80003ab4:	9f35                	addw	a4,a4,a3
    return 0;
    80003ab6:	4501                	li	a0,0
  if(off > ip->size || off + n < off)
    80003ab8:	0ad76063          	bltu	a4,a3,80003b58 <readi+0xd2>
  if(off + n > ip->size)
    80003abc:	00e7f463          	bleu	a4,a5,80003ac4 <readi+0x3e>
    n = ip->size - off;
    80003ac0:	40d78b3b          	subw	s6,a5,a3

  for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
    80003ac4:	0a0b0963          	beqz	s6,80003b76 <readi+0xf0>
    80003ac8:	4901                	li	s2,0
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    m = min(n - tot, BSIZE - off%BSIZE);
    80003aca:	40000d13          	li	s10,1024
    if(either_copyout(user_dst, dst, bp->data + (off % BSIZE), m) == -1) {
    80003ace:	5cfd                	li	s9,-1
    80003ad0:	a82d                	j	80003b0a <readi+0x84>
    80003ad2:	02099d93          	slli	s11,s3,0x20
    80003ad6:	020ddd93          	srli	s11,s11,0x20
    80003ada:	058a8613          	addi	a2,s5,88
    80003ade:	86ee                	mv	a3,s11
    80003ae0:	963a                	add	a2,a2,a4
    80003ae2:	85d2                	mv	a1,s4
    80003ae4:	8562                	mv	a0,s8
    80003ae6:	fffff097          	auipc	ra,0xfffff
    80003aea:	a2e080e7          	jalr	-1490(ra) # 80002514 <either_copyout>
    80003aee:	05950d63          	beq	a0,s9,80003b48 <readi+0xc2>
      brelse(bp);
      tot = -1;
      break;
    }
    brelse(bp);
    80003af2:	8556                	mv	a0,s5
    80003af4:	fffff097          	auipc	ra,0xfffff
    80003af8:	5d6080e7          	jalr	1494(ra) # 800030ca <brelse>
  for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
    80003afc:	0129893b          	addw	s2,s3,s2
    80003b00:	009984bb          	addw	s1,s3,s1
    80003b04:	9a6e                	add	s4,s4,s11
    80003b06:	05697763          	bleu	s6,s2,80003b54 <readi+0xce>
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    80003b0a:	000ba983          	lw	s3,0(s7)
    80003b0e:	00a4d59b          	srliw	a1,s1,0xa
    80003b12:	855e                	mv	a0,s7
    80003b14:	00000097          	auipc	ra,0x0
    80003b18:	8ac080e7          	jalr	-1876(ra) # 800033c0 <bmap>
    80003b1c:	0005059b          	sext.w	a1,a0
    80003b20:	854e                	mv	a0,s3
    80003b22:	fffff097          	auipc	ra,0xfffff
    80003b26:	466080e7          	jalr	1126(ra) # 80002f88 <bread>
    80003b2a:	8aaa                	mv	s5,a0
    m = min(n - tot, BSIZE - off%BSIZE);
    80003b2c:	3ff4f713          	andi	a4,s1,1023
    80003b30:	40ed07bb          	subw	a5,s10,a4
    80003b34:	412b06bb          	subw	a3,s6,s2
    80003b38:	89be                	mv	s3,a5
    80003b3a:	2781                	sext.w	a5,a5
    80003b3c:	0006861b          	sext.w	a2,a3
    80003b40:	f8f679e3          	bleu	a5,a2,80003ad2 <readi+0x4c>
    80003b44:	89b6                	mv	s3,a3
    80003b46:	b771                	j	80003ad2 <readi+0x4c>
      brelse(bp);
    80003b48:	8556                	mv	a0,s5
    80003b4a:	fffff097          	auipc	ra,0xfffff
    80003b4e:	580080e7          	jalr	1408(ra) # 800030ca <brelse>
      tot = -1;
    80003b52:	597d                	li	s2,-1
  }
  return tot;
    80003b54:	0009051b          	sext.w	a0,s2
}
    80003b58:	70a6                	ld	ra,104(sp)
    80003b5a:	7406                	ld	s0,96(sp)
    80003b5c:	64e6                	ld	s1,88(sp)
    80003b5e:	6946                	ld	s2,80(sp)
    80003b60:	69a6                	ld	s3,72(sp)
    80003b62:	6a06                	ld	s4,64(sp)
    80003b64:	7ae2                	ld	s5,56(sp)
    80003b66:	7b42                	ld	s6,48(sp)
    80003b68:	7ba2                	ld	s7,40(sp)
    80003b6a:	7c02                	ld	s8,32(sp)
    80003b6c:	6ce2                	ld	s9,24(sp)
    80003b6e:	6d42                	ld	s10,16(sp)
    80003b70:	6da2                	ld	s11,8(sp)
    80003b72:	6165                	addi	sp,sp,112
    80003b74:	8082                	ret
  for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
    80003b76:	895a                	mv	s2,s6
    80003b78:	bff1                	j	80003b54 <readi+0xce>
    return 0;
    80003b7a:	4501                	li	a0,0
}
    80003b7c:	8082                	ret

0000000080003b7e <writei>:
writei(struct inode *ip, int user_src, uint64 src, uint off, uint n)
{
  uint tot, m;
  struct buf *bp;

  if(off > ip->size || off + n < off)
    80003b7e:	457c                	lw	a5,76(a0)
    80003b80:	10d7e763          	bltu	a5,a3,80003c8e <writei+0x110>
{
    80003b84:	7159                	addi	sp,sp,-112
    80003b86:	f486                	sd	ra,104(sp)
    80003b88:	f0a2                	sd	s0,96(sp)
    80003b8a:	eca6                	sd	s1,88(sp)
    80003b8c:	e8ca                	sd	s2,80(sp)
    80003b8e:	e4ce                	sd	s3,72(sp)
    80003b90:	e0d2                	sd	s4,64(sp)
    80003b92:	fc56                	sd	s5,56(sp)
    80003b94:	f85a                	sd	s6,48(sp)
    80003b96:	f45e                	sd	s7,40(sp)
    80003b98:	f062                	sd	s8,32(sp)
    80003b9a:	ec66                	sd	s9,24(sp)
    80003b9c:	e86a                	sd	s10,16(sp)
    80003b9e:	e46e                	sd	s11,8(sp)
    80003ba0:	1880                	addi	s0,sp,112
    80003ba2:	8baa                	mv	s7,a0
    80003ba4:	8c2e                	mv	s8,a1
    80003ba6:	8ab2                	mv	s5,a2
    80003ba8:	84b6                	mv	s1,a3
    80003baa:	8b3a                	mv	s6,a4
  if(off > ip->size || off + n < off)
    80003bac:	00e687bb          	addw	a5,a3,a4
    80003bb0:	0ed7e163          	bltu	a5,a3,80003c92 <writei+0x114>
    return -1;
  if(off + n > MAXFILE*BSIZE)
    80003bb4:	00043737          	lui	a4,0x43
    80003bb8:	0cf76f63          	bltu	a4,a5,80003c96 <writei+0x118>
    return -1;

  for(tot=0; tot<n; tot+=m, off+=m, src+=m){
    80003bbc:	0a0b0863          	beqz	s6,80003c6c <writei+0xee>
    80003bc0:	4a01                	li	s4,0
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    m = min(n - tot, BSIZE - off%BSIZE);
    80003bc2:	40000d13          	li	s10,1024
    if(either_copyin(bp->data + (off % BSIZE), user_src, src, m) == -1) {
    80003bc6:	5cfd                	li	s9,-1
    80003bc8:	a091                	j	80003c0c <writei+0x8e>
    80003bca:	02091d93          	slli	s11,s2,0x20
    80003bce:	020ddd93          	srli	s11,s11,0x20
    80003bd2:	05898513          	addi	a0,s3,88
    80003bd6:	86ee                	mv	a3,s11
    80003bd8:	8656                	mv	a2,s5
    80003bda:	85e2                	mv	a1,s8
    80003bdc:	953a                	add	a0,a0,a4
    80003bde:	fffff097          	auipc	ra,0xfffff
    80003be2:	98c080e7          	jalr	-1652(ra) # 8000256a <either_copyin>
    80003be6:	07950263          	beq	a0,s9,80003c4a <writei+0xcc>
      brelse(bp);
      n = -1;
      break;
    }
    log_write(bp);
    80003bea:	854e                	mv	a0,s3
    80003bec:	00000097          	auipc	ra,0x0
    80003bf0:	78c080e7          	jalr	1932(ra) # 80004378 <log_write>
    brelse(bp);
    80003bf4:	854e                	mv	a0,s3
    80003bf6:	fffff097          	auipc	ra,0xfffff
    80003bfa:	4d4080e7          	jalr	1236(ra) # 800030ca <brelse>
  for(tot=0; tot<n; tot+=m, off+=m, src+=m){
    80003bfe:	01490a3b          	addw	s4,s2,s4
    80003c02:	009904bb          	addw	s1,s2,s1
    80003c06:	9aee                	add	s5,s5,s11
    80003c08:	056a7763          	bleu	s6,s4,80003c56 <writei+0xd8>
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    80003c0c:	000ba903          	lw	s2,0(s7)
    80003c10:	00a4d59b          	srliw	a1,s1,0xa
    80003c14:	855e                	mv	a0,s7
    80003c16:	fffff097          	auipc	ra,0xfffff
    80003c1a:	7aa080e7          	jalr	1962(ra) # 800033c0 <bmap>
    80003c1e:	0005059b          	sext.w	a1,a0
    80003c22:	854a                	mv	a0,s2
    80003c24:	fffff097          	auipc	ra,0xfffff
    80003c28:	364080e7          	jalr	868(ra) # 80002f88 <bread>
    80003c2c:	89aa                	mv	s3,a0
    m = min(n - tot, BSIZE - off%BSIZE);
    80003c2e:	3ff4f713          	andi	a4,s1,1023
    80003c32:	40ed07bb          	subw	a5,s10,a4
    80003c36:	414b06bb          	subw	a3,s6,s4
    80003c3a:	893e                	mv	s2,a5
    80003c3c:	2781                	sext.w	a5,a5
    80003c3e:	0006861b          	sext.w	a2,a3
    80003c42:	f8f674e3          	bleu	a5,a2,80003bca <writei+0x4c>
    80003c46:	8936                	mv	s2,a3
    80003c48:	b749                	j	80003bca <writei+0x4c>
      brelse(bp);
    80003c4a:	854e                	mv	a0,s3
    80003c4c:	fffff097          	auipc	ra,0xfffff
    80003c50:	47e080e7          	jalr	1150(ra) # 800030ca <brelse>
      n = -1;
    80003c54:	5b7d                	li	s6,-1
  }

  if(n > 0){
    if(off > ip->size)
    80003c56:	04cba783          	lw	a5,76(s7)
    80003c5a:	0097f463          	bleu	s1,a5,80003c62 <writei+0xe4>
      ip->size = off;
    80003c5e:	049ba623          	sw	s1,76(s7)
    // write the i-node back to disk even if the size didn't change
    // because the loop above might have called bmap() and added a new
    // block to ip->addrs[].
    iupdate(ip);
    80003c62:	855e                	mv	a0,s7
    80003c64:	00000097          	auipc	ra,0x0
    80003c68:	aa0080e7          	jalr	-1376(ra) # 80003704 <iupdate>
  }

  return n;
    80003c6c:	000b051b          	sext.w	a0,s6
}
    80003c70:	70a6                	ld	ra,104(sp)
    80003c72:	7406                	ld	s0,96(sp)
    80003c74:	64e6                	ld	s1,88(sp)
    80003c76:	6946                	ld	s2,80(sp)
    80003c78:	69a6                	ld	s3,72(sp)
    80003c7a:	6a06                	ld	s4,64(sp)
    80003c7c:	7ae2                	ld	s5,56(sp)
    80003c7e:	7b42                	ld	s6,48(sp)
    80003c80:	7ba2                	ld	s7,40(sp)
    80003c82:	7c02                	ld	s8,32(sp)
    80003c84:	6ce2                	ld	s9,24(sp)
    80003c86:	6d42                	ld	s10,16(sp)
    80003c88:	6da2                	ld	s11,8(sp)
    80003c8a:	6165                	addi	sp,sp,112
    80003c8c:	8082                	ret
    return -1;
    80003c8e:	557d                	li	a0,-1
}
    80003c90:	8082                	ret
    return -1;
    80003c92:	557d                	li	a0,-1
    80003c94:	bff1                	j	80003c70 <writei+0xf2>
    return -1;
    80003c96:	557d                	li	a0,-1
    80003c98:	bfe1                	j	80003c70 <writei+0xf2>

0000000080003c9a <namecmp>:

// Directories

int
namecmp(const char *s, const char *t)
{
    80003c9a:	1141                	addi	sp,sp,-16
    80003c9c:	e406                	sd	ra,8(sp)
    80003c9e:	e022                	sd	s0,0(sp)
    80003ca0:	0800                	addi	s0,sp,16
  return strncmp(s, t, DIRSIZ);
    80003ca2:	4639                	li	a2,14
    80003ca4:	ffffd097          	auipc	ra,0xffffd
    80003ca8:	1a2080e7          	jalr	418(ra) # 80000e46 <strncmp>
}
    80003cac:	60a2                	ld	ra,8(sp)
    80003cae:	6402                	ld	s0,0(sp)
    80003cb0:	0141                	addi	sp,sp,16
    80003cb2:	8082                	ret

0000000080003cb4 <dirlookup>:

// Look for a directory entry in a directory.
// If found, set *poff to byte offset of entry.
struct inode*
dirlookup(struct inode *dp, char *name, uint *poff)
{
    80003cb4:	7139                	addi	sp,sp,-64
    80003cb6:	fc06                	sd	ra,56(sp)
    80003cb8:	f822                	sd	s0,48(sp)
    80003cba:	f426                	sd	s1,40(sp)
    80003cbc:	f04a                	sd	s2,32(sp)
    80003cbe:	ec4e                	sd	s3,24(sp)
    80003cc0:	e852                	sd	s4,16(sp)
    80003cc2:	0080                	addi	s0,sp,64
  uint off, inum;
  struct dirent de;

  if(dp->type != T_DIR)
    80003cc4:	04451703          	lh	a4,68(a0)
    80003cc8:	4785                	li	a5,1
    80003cca:	00f71a63          	bne	a4,a5,80003cde <dirlookup+0x2a>
    80003cce:	892a                	mv	s2,a0
    80003cd0:	89ae                	mv	s3,a1
    80003cd2:	8a32                	mv	s4,a2
    panic("dirlookup not DIR");

  for(off = 0; off < dp->size; off += sizeof(de)){
    80003cd4:	457c                	lw	a5,76(a0)
    80003cd6:	4481                	li	s1,0
      inum = de.inum;
      return iget(dp->dev, inum);
    }
  }

  return 0;
    80003cd8:	4501                	li	a0,0
  for(off = 0; off < dp->size; off += sizeof(de)){
    80003cda:	e79d                	bnez	a5,80003d08 <dirlookup+0x54>
    80003cdc:	a8a5                	j	80003d54 <dirlookup+0xa0>
    panic("dirlookup not DIR");
    80003cde:	00005517          	auipc	a0,0x5
    80003ce2:	88250513          	addi	a0,a0,-1918 # 80008560 <syscalls+0x1c8>
    80003ce6:	ffffd097          	auipc	ra,0xffffd
    80003cea:	88e080e7          	jalr	-1906(ra) # 80000574 <panic>
      panic("dirlookup read");
    80003cee:	00005517          	auipc	a0,0x5
    80003cf2:	88a50513          	addi	a0,a0,-1910 # 80008578 <syscalls+0x1e0>
    80003cf6:	ffffd097          	auipc	ra,0xffffd
    80003cfa:	87e080e7          	jalr	-1922(ra) # 80000574 <panic>
  for(off = 0; off < dp->size; off += sizeof(de)){
    80003cfe:	24c1                	addiw	s1,s1,16
    80003d00:	04c92783          	lw	a5,76(s2)
    80003d04:	04f4f763          	bleu	a5,s1,80003d52 <dirlookup+0x9e>
    if(readi(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    80003d08:	4741                	li	a4,16
    80003d0a:	86a6                	mv	a3,s1
    80003d0c:	fc040613          	addi	a2,s0,-64
    80003d10:	4581                	li	a1,0
    80003d12:	854a                	mv	a0,s2
    80003d14:	00000097          	auipc	ra,0x0
    80003d18:	d72080e7          	jalr	-654(ra) # 80003a86 <readi>
    80003d1c:	47c1                	li	a5,16
    80003d1e:	fcf518e3          	bne	a0,a5,80003cee <dirlookup+0x3a>
    if(de.inum == 0)
    80003d22:	fc045783          	lhu	a5,-64(s0)
    80003d26:	dfe1                	beqz	a5,80003cfe <dirlookup+0x4a>
    if(namecmp(name, de.name) == 0){
    80003d28:	fc240593          	addi	a1,s0,-62
    80003d2c:	854e                	mv	a0,s3
    80003d2e:	00000097          	auipc	ra,0x0
    80003d32:	f6c080e7          	jalr	-148(ra) # 80003c9a <namecmp>
    80003d36:	f561                	bnez	a0,80003cfe <dirlookup+0x4a>
      if(poff)
    80003d38:	000a0463          	beqz	s4,80003d40 <dirlookup+0x8c>
        *poff = off;
    80003d3c:	009a2023          	sw	s1,0(s4) # 2000 <_entry-0x7fffe000>
      return iget(dp->dev, inum);
    80003d40:	fc045583          	lhu	a1,-64(s0)
    80003d44:	00092503          	lw	a0,0(s2)
    80003d48:	fffff097          	auipc	ra,0xfffff
    80003d4c:	752080e7          	jalr	1874(ra) # 8000349a <iget>
    80003d50:	a011                	j	80003d54 <dirlookup+0xa0>
  return 0;
    80003d52:	4501                	li	a0,0
}
    80003d54:	70e2                	ld	ra,56(sp)
    80003d56:	7442                	ld	s0,48(sp)
    80003d58:	74a2                	ld	s1,40(sp)
    80003d5a:	7902                	ld	s2,32(sp)
    80003d5c:	69e2                	ld	s3,24(sp)
    80003d5e:	6a42                	ld	s4,16(sp)
    80003d60:	6121                	addi	sp,sp,64
    80003d62:	8082                	ret

0000000080003d64 <namex>:
// If parent != 0, return the inode for the parent and copy the final
// path element into name, which must have room for DIRSIZ bytes.
// Must be called inside a transaction since it calls iput().
static struct inode*
namex(char *path, int nameiparent, char *name)
{
    80003d64:	711d                	addi	sp,sp,-96
    80003d66:	ec86                	sd	ra,88(sp)
    80003d68:	e8a2                	sd	s0,80(sp)
    80003d6a:	e4a6                	sd	s1,72(sp)
    80003d6c:	e0ca                	sd	s2,64(sp)
    80003d6e:	fc4e                	sd	s3,56(sp)
    80003d70:	f852                	sd	s4,48(sp)
    80003d72:	f456                	sd	s5,40(sp)
    80003d74:	f05a                	sd	s6,32(sp)
    80003d76:	ec5e                	sd	s7,24(sp)
    80003d78:	e862                	sd	s8,16(sp)
    80003d7a:	e466                	sd	s9,8(sp)
    80003d7c:	1080                	addi	s0,sp,96
    80003d7e:	84aa                	mv	s1,a0
    80003d80:	8bae                	mv	s7,a1
    80003d82:	8ab2                	mv	s5,a2
  struct inode *ip, *next;

  if(*path == '/')
    80003d84:	00054703          	lbu	a4,0(a0)
    80003d88:	02f00793          	li	a5,47
    80003d8c:	02f70363          	beq	a4,a5,80003db2 <namex+0x4e>
    ip = iget(ROOTDEV, ROOTINO);
  else
    ip = idup(myproc()->cwd);
    80003d90:	ffffe097          	auipc	ra,0xffffe
    80003d94:	d08080e7          	jalr	-760(ra) # 80001a98 <myproc>
    80003d98:	15053503          	ld	a0,336(a0)
    80003d9c:	00000097          	auipc	ra,0x0
    80003da0:	9f6080e7          	jalr	-1546(ra) # 80003792 <idup>
    80003da4:	89aa                	mv	s3,a0
  while(*path == '/')
    80003da6:	02f00913          	li	s2,47
  len = path - s;
    80003daa:	4b01                	li	s6,0
  if(len >= DIRSIZ)
    80003dac:	4cb5                	li	s9,13

  while((path = skipelem(path, name)) != 0){
    ilock(ip);
    if(ip->type != T_DIR){
    80003dae:	4c05                	li	s8,1
    80003db0:	a865                	j	80003e68 <namex+0x104>
    ip = iget(ROOTDEV, ROOTINO);
    80003db2:	4585                	li	a1,1
    80003db4:	4505                	li	a0,1
    80003db6:	fffff097          	auipc	ra,0xfffff
    80003dba:	6e4080e7          	jalr	1764(ra) # 8000349a <iget>
    80003dbe:	89aa                	mv	s3,a0
    80003dc0:	b7dd                	j	80003da6 <namex+0x42>
      iunlockput(ip);
    80003dc2:	854e                	mv	a0,s3
    80003dc4:	00000097          	auipc	ra,0x0
    80003dc8:	c70080e7          	jalr	-912(ra) # 80003a34 <iunlockput>
      return 0;
    80003dcc:	4981                	li	s3,0
  if(nameiparent){
    iput(ip);
    return 0;
  }
  return ip;
}
    80003dce:	854e                	mv	a0,s3
    80003dd0:	60e6                	ld	ra,88(sp)
    80003dd2:	6446                	ld	s0,80(sp)
    80003dd4:	64a6                	ld	s1,72(sp)
    80003dd6:	6906                	ld	s2,64(sp)
    80003dd8:	79e2                	ld	s3,56(sp)
    80003dda:	7a42                	ld	s4,48(sp)
    80003ddc:	7aa2                	ld	s5,40(sp)
    80003dde:	7b02                	ld	s6,32(sp)
    80003de0:	6be2                	ld	s7,24(sp)
    80003de2:	6c42                	ld	s8,16(sp)
    80003de4:	6ca2                	ld	s9,8(sp)
    80003de6:	6125                	addi	sp,sp,96
    80003de8:	8082                	ret
      iunlock(ip);
    80003dea:	854e                	mv	a0,s3
    80003dec:	00000097          	auipc	ra,0x0
    80003df0:	aa8080e7          	jalr	-1368(ra) # 80003894 <iunlock>
      return ip;
    80003df4:	bfe9                	j	80003dce <namex+0x6a>
      iunlockput(ip);
    80003df6:	854e                	mv	a0,s3
    80003df8:	00000097          	auipc	ra,0x0
    80003dfc:	c3c080e7          	jalr	-964(ra) # 80003a34 <iunlockput>
      return 0;
    80003e00:	89d2                	mv	s3,s4
    80003e02:	b7f1                	j	80003dce <namex+0x6a>
  len = path - s;
    80003e04:	40b48633          	sub	a2,s1,a1
    80003e08:	00060a1b          	sext.w	s4,a2
  if(len >= DIRSIZ)
    80003e0c:	094cd663          	ble	s4,s9,80003e98 <namex+0x134>
    memmove(name, s, DIRSIZ);
    80003e10:	4639                	li	a2,14
    80003e12:	8556                	mv	a0,s5
    80003e14:	ffffd097          	auipc	ra,0xffffd
    80003e18:	fb6080e7          	jalr	-74(ra) # 80000dca <memmove>
  while(*path == '/')
    80003e1c:	0004c783          	lbu	a5,0(s1)
    80003e20:	01279763          	bne	a5,s2,80003e2e <namex+0xca>
    path++;
    80003e24:	0485                	addi	s1,s1,1
  while(*path == '/')
    80003e26:	0004c783          	lbu	a5,0(s1)
    80003e2a:	ff278de3          	beq	a5,s2,80003e24 <namex+0xc0>
    ilock(ip);
    80003e2e:	854e                	mv	a0,s3
    80003e30:	00000097          	auipc	ra,0x0
    80003e34:	9a0080e7          	jalr	-1632(ra) # 800037d0 <ilock>
    if(ip->type != T_DIR){
    80003e38:	04499783          	lh	a5,68(s3)
    80003e3c:	f98793e3          	bne	a5,s8,80003dc2 <namex+0x5e>
    if(nameiparent && *path == '\0'){
    80003e40:	000b8563          	beqz	s7,80003e4a <namex+0xe6>
    80003e44:	0004c783          	lbu	a5,0(s1)
    80003e48:	d3cd                	beqz	a5,80003dea <namex+0x86>
    if((next = dirlookup(ip, name, 0)) == 0){
    80003e4a:	865a                	mv	a2,s6
    80003e4c:	85d6                	mv	a1,s5
    80003e4e:	854e                	mv	a0,s3
    80003e50:	00000097          	auipc	ra,0x0
    80003e54:	e64080e7          	jalr	-412(ra) # 80003cb4 <dirlookup>
    80003e58:	8a2a                	mv	s4,a0
    80003e5a:	dd51                	beqz	a0,80003df6 <namex+0x92>
    iunlockput(ip);
    80003e5c:	854e                	mv	a0,s3
    80003e5e:	00000097          	auipc	ra,0x0
    80003e62:	bd6080e7          	jalr	-1066(ra) # 80003a34 <iunlockput>
    ip = next;
    80003e66:	89d2                	mv	s3,s4
  while(*path == '/')
    80003e68:	0004c783          	lbu	a5,0(s1)
    80003e6c:	05279d63          	bne	a5,s2,80003ec6 <namex+0x162>
    path++;
    80003e70:	0485                	addi	s1,s1,1
  while(*path == '/')
    80003e72:	0004c783          	lbu	a5,0(s1)
    80003e76:	ff278de3          	beq	a5,s2,80003e70 <namex+0x10c>
  if(*path == 0)
    80003e7a:	cf8d                	beqz	a5,80003eb4 <namex+0x150>
  while(*path != '/' && *path != 0)
    80003e7c:	01278b63          	beq	a5,s2,80003e92 <namex+0x12e>
    80003e80:	c795                	beqz	a5,80003eac <namex+0x148>
    path++;
    80003e82:	85a6                	mv	a1,s1
    path++;
    80003e84:	0485                	addi	s1,s1,1
  while(*path != '/' && *path != 0)
    80003e86:	0004c783          	lbu	a5,0(s1)
    80003e8a:	f7278de3          	beq	a5,s2,80003e04 <namex+0xa0>
    80003e8e:	fbfd                	bnez	a5,80003e84 <namex+0x120>
    80003e90:	bf95                	j	80003e04 <namex+0xa0>
    80003e92:	85a6                	mv	a1,s1
  len = path - s;
    80003e94:	8a5a                	mv	s4,s6
    80003e96:	865a                	mv	a2,s6
    memmove(name, s, len);
    80003e98:	2601                	sext.w	a2,a2
    80003e9a:	8556                	mv	a0,s5
    80003e9c:	ffffd097          	auipc	ra,0xffffd
    80003ea0:	f2e080e7          	jalr	-210(ra) # 80000dca <memmove>
    name[len] = 0;
    80003ea4:	9a56                	add	s4,s4,s5
    80003ea6:	000a0023          	sb	zero,0(s4)
    80003eaa:	bf8d                	j	80003e1c <namex+0xb8>
  while(*path != '/' && *path != 0)
    80003eac:	85a6                	mv	a1,s1
  len = path - s;
    80003eae:	8a5a                	mv	s4,s6
    80003eb0:	865a                	mv	a2,s6
    80003eb2:	b7dd                	j	80003e98 <namex+0x134>
  if(nameiparent){
    80003eb4:	f00b8de3          	beqz	s7,80003dce <namex+0x6a>
    iput(ip);
    80003eb8:	854e                	mv	a0,s3
    80003eba:	00000097          	auipc	ra,0x0
    80003ebe:	ad2080e7          	jalr	-1326(ra) # 8000398c <iput>
    return 0;
    80003ec2:	4981                	li	s3,0
    80003ec4:	b729                	j	80003dce <namex+0x6a>
  if(*path == 0)
    80003ec6:	d7fd                	beqz	a5,80003eb4 <namex+0x150>
    80003ec8:	85a6                	mv	a1,s1
    80003eca:	bf6d                	j	80003e84 <namex+0x120>

0000000080003ecc <dirlink>:
{
    80003ecc:	7139                	addi	sp,sp,-64
    80003ece:	fc06                	sd	ra,56(sp)
    80003ed0:	f822                	sd	s0,48(sp)
    80003ed2:	f426                	sd	s1,40(sp)
    80003ed4:	f04a                	sd	s2,32(sp)
    80003ed6:	ec4e                	sd	s3,24(sp)
    80003ed8:	e852                	sd	s4,16(sp)
    80003eda:	0080                	addi	s0,sp,64
    80003edc:	892a                	mv	s2,a0
    80003ede:	8a2e                	mv	s4,a1
    80003ee0:	89b2                	mv	s3,a2
  if((ip = dirlookup(dp, name, 0)) != 0){
    80003ee2:	4601                	li	a2,0
    80003ee4:	00000097          	auipc	ra,0x0
    80003ee8:	dd0080e7          	jalr	-560(ra) # 80003cb4 <dirlookup>
    80003eec:	e93d                	bnez	a0,80003f62 <dirlink+0x96>
  for(off = 0; off < dp->size; off += sizeof(de)){
    80003eee:	04c92483          	lw	s1,76(s2)
    80003ef2:	c49d                	beqz	s1,80003f20 <dirlink+0x54>
    80003ef4:	4481                	li	s1,0
    if(readi(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    80003ef6:	4741                	li	a4,16
    80003ef8:	86a6                	mv	a3,s1
    80003efa:	fc040613          	addi	a2,s0,-64
    80003efe:	4581                	li	a1,0
    80003f00:	854a                	mv	a0,s2
    80003f02:	00000097          	auipc	ra,0x0
    80003f06:	b84080e7          	jalr	-1148(ra) # 80003a86 <readi>
    80003f0a:	47c1                	li	a5,16
    80003f0c:	06f51163          	bne	a0,a5,80003f6e <dirlink+0xa2>
    if(de.inum == 0)
    80003f10:	fc045783          	lhu	a5,-64(s0)
    80003f14:	c791                	beqz	a5,80003f20 <dirlink+0x54>
  for(off = 0; off < dp->size; off += sizeof(de)){
    80003f16:	24c1                	addiw	s1,s1,16
    80003f18:	04c92783          	lw	a5,76(s2)
    80003f1c:	fcf4ede3          	bltu	s1,a5,80003ef6 <dirlink+0x2a>
  strncpy(de.name, name, DIRSIZ);
    80003f20:	4639                	li	a2,14
    80003f22:	85d2                	mv	a1,s4
    80003f24:	fc240513          	addi	a0,s0,-62
    80003f28:	ffffd097          	auipc	ra,0xffffd
    80003f2c:	f6e080e7          	jalr	-146(ra) # 80000e96 <strncpy>
  de.inum = inum;
    80003f30:	fd341023          	sh	s3,-64(s0)
  if(writei(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    80003f34:	4741                	li	a4,16
    80003f36:	86a6                	mv	a3,s1
    80003f38:	fc040613          	addi	a2,s0,-64
    80003f3c:	4581                	li	a1,0
    80003f3e:	854a                	mv	a0,s2
    80003f40:	00000097          	auipc	ra,0x0
    80003f44:	c3e080e7          	jalr	-962(ra) # 80003b7e <writei>
    80003f48:	4741                	li	a4,16
  return 0;
    80003f4a:	4781                	li	a5,0
  if(writei(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    80003f4c:	02e51963          	bne	a0,a4,80003f7e <dirlink+0xb2>
}
    80003f50:	853e                	mv	a0,a5
    80003f52:	70e2                	ld	ra,56(sp)
    80003f54:	7442                	ld	s0,48(sp)
    80003f56:	74a2                	ld	s1,40(sp)
    80003f58:	7902                	ld	s2,32(sp)
    80003f5a:	69e2                	ld	s3,24(sp)
    80003f5c:	6a42                	ld	s4,16(sp)
    80003f5e:	6121                	addi	sp,sp,64
    80003f60:	8082                	ret
    iput(ip);
    80003f62:	00000097          	auipc	ra,0x0
    80003f66:	a2a080e7          	jalr	-1494(ra) # 8000398c <iput>
    return -1;
    80003f6a:	57fd                	li	a5,-1
    80003f6c:	b7d5                	j	80003f50 <dirlink+0x84>
      panic("dirlink read");
    80003f6e:	00004517          	auipc	a0,0x4
    80003f72:	61a50513          	addi	a0,a0,1562 # 80008588 <syscalls+0x1f0>
    80003f76:	ffffc097          	auipc	ra,0xffffc
    80003f7a:	5fe080e7          	jalr	1534(ra) # 80000574 <panic>
    panic("dirlink");
    80003f7e:	00004517          	auipc	a0,0x4
    80003f82:	72a50513          	addi	a0,a0,1834 # 800086a8 <syscalls+0x310>
    80003f86:	ffffc097          	auipc	ra,0xffffc
    80003f8a:	5ee080e7          	jalr	1518(ra) # 80000574 <panic>

0000000080003f8e <namei>:

struct inode*
namei(char *path)
{
    80003f8e:	1101                	addi	sp,sp,-32
    80003f90:	ec06                	sd	ra,24(sp)
    80003f92:	e822                	sd	s0,16(sp)
    80003f94:	1000                	addi	s0,sp,32
  char name[DIRSIZ];
  return namex(path, 0, name);
    80003f96:	fe040613          	addi	a2,s0,-32
    80003f9a:	4581                	li	a1,0
    80003f9c:	00000097          	auipc	ra,0x0
    80003fa0:	dc8080e7          	jalr	-568(ra) # 80003d64 <namex>
}
    80003fa4:	60e2                	ld	ra,24(sp)
    80003fa6:	6442                	ld	s0,16(sp)
    80003fa8:	6105                	addi	sp,sp,32
    80003faa:	8082                	ret

0000000080003fac <nameiparent>:

struct inode*
nameiparent(char *path, char *name)
{
    80003fac:	1141                	addi	sp,sp,-16
    80003fae:	e406                	sd	ra,8(sp)
    80003fb0:	e022                	sd	s0,0(sp)
    80003fb2:	0800                	addi	s0,sp,16
  return namex(path, 1, name);
    80003fb4:	862e                	mv	a2,a1
    80003fb6:	4585                	li	a1,1
    80003fb8:	00000097          	auipc	ra,0x0
    80003fbc:	dac080e7          	jalr	-596(ra) # 80003d64 <namex>
}
    80003fc0:	60a2                	ld	ra,8(sp)
    80003fc2:	6402                	ld	s0,0(sp)
    80003fc4:	0141                	addi	sp,sp,16
    80003fc6:	8082                	ret

0000000080003fc8 <write_head>:
// Write in-memory log header to disk.
// This is the true point at which the
// current transaction commits.
static void
write_head(void)
{
    80003fc8:	1101                	addi	sp,sp,-32
    80003fca:	ec06                	sd	ra,24(sp)
    80003fcc:	e822                	sd	s0,16(sp)
    80003fce:	e426                	sd	s1,8(sp)
    80003fd0:	e04a                	sd	s2,0(sp)
    80003fd2:	1000                	addi	s0,sp,32
  struct buf *buf = bread(log.dev, log.start);
    80003fd4:	0001e917          	auipc	s2,0x1e
    80003fd8:	93490913          	addi	s2,s2,-1740 # 80021908 <log>
    80003fdc:	01892583          	lw	a1,24(s2)
    80003fe0:	02892503          	lw	a0,40(s2)
    80003fe4:	fffff097          	auipc	ra,0xfffff
    80003fe8:	fa4080e7          	jalr	-92(ra) # 80002f88 <bread>
    80003fec:	84aa                	mv	s1,a0
  struct logheader *hb = (struct logheader *) (buf->data);
  int i;
  hb->n = log.lh.n;
    80003fee:	02c92683          	lw	a3,44(s2)
    80003ff2:	cd34                	sw	a3,88(a0)
  for (i = 0; i < log.lh.n; i++) {
    80003ff4:	02d05763          	blez	a3,80004022 <write_head+0x5a>
    80003ff8:	0001e797          	auipc	a5,0x1e
    80003ffc:	94078793          	addi	a5,a5,-1728 # 80021938 <log+0x30>
    80004000:	05c50713          	addi	a4,a0,92
    80004004:	36fd                	addiw	a3,a3,-1
    80004006:	1682                	slli	a3,a3,0x20
    80004008:	9281                	srli	a3,a3,0x20
    8000400a:	068a                	slli	a3,a3,0x2
    8000400c:	0001e617          	auipc	a2,0x1e
    80004010:	93060613          	addi	a2,a2,-1744 # 8002193c <log+0x34>
    80004014:	96b2                	add	a3,a3,a2
    hb->block[i] = log.lh.block[i];
    80004016:	4390                	lw	a2,0(a5)
    80004018:	c310                	sw	a2,0(a4)
  for (i = 0; i < log.lh.n; i++) {
    8000401a:	0791                	addi	a5,a5,4
    8000401c:	0711                	addi	a4,a4,4
    8000401e:	fed79ce3          	bne	a5,a3,80004016 <write_head+0x4e>
  }
  bwrite(buf);
    80004022:	8526                	mv	a0,s1
    80004024:	fffff097          	auipc	ra,0xfffff
    80004028:	068080e7          	jalr	104(ra) # 8000308c <bwrite>
  brelse(buf);
    8000402c:	8526                	mv	a0,s1
    8000402e:	fffff097          	auipc	ra,0xfffff
    80004032:	09c080e7          	jalr	156(ra) # 800030ca <brelse>
}
    80004036:	60e2                	ld	ra,24(sp)
    80004038:	6442                	ld	s0,16(sp)
    8000403a:	64a2                	ld	s1,8(sp)
    8000403c:	6902                	ld	s2,0(sp)
    8000403e:	6105                	addi	sp,sp,32
    80004040:	8082                	ret

0000000080004042 <install_trans>:
  for (tail = 0; tail < log.lh.n; tail++) {
    80004042:	0001e797          	auipc	a5,0x1e
    80004046:	8c678793          	addi	a5,a5,-1850 # 80021908 <log>
    8000404a:	57dc                	lw	a5,44(a5)
    8000404c:	0af05663          	blez	a5,800040f8 <install_trans+0xb6>
{
    80004050:	7139                	addi	sp,sp,-64
    80004052:	fc06                	sd	ra,56(sp)
    80004054:	f822                	sd	s0,48(sp)
    80004056:	f426                	sd	s1,40(sp)
    80004058:	f04a                	sd	s2,32(sp)
    8000405a:	ec4e                	sd	s3,24(sp)
    8000405c:	e852                	sd	s4,16(sp)
    8000405e:	e456                	sd	s5,8(sp)
    80004060:	0080                	addi	s0,sp,64
    80004062:	0001ea17          	auipc	s4,0x1e
    80004066:	8d6a0a13          	addi	s4,s4,-1834 # 80021938 <log+0x30>
  for (tail = 0; tail < log.lh.n; tail++) {
    8000406a:	4981                	li	s3,0
    struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block
    8000406c:	0001e917          	auipc	s2,0x1e
    80004070:	89c90913          	addi	s2,s2,-1892 # 80021908 <log>
    80004074:	01892583          	lw	a1,24(s2)
    80004078:	013585bb          	addw	a1,a1,s3
    8000407c:	2585                	addiw	a1,a1,1
    8000407e:	02892503          	lw	a0,40(s2)
    80004082:	fffff097          	auipc	ra,0xfffff
    80004086:	f06080e7          	jalr	-250(ra) # 80002f88 <bread>
    8000408a:	8aaa                	mv	s5,a0
    struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst
    8000408c:	000a2583          	lw	a1,0(s4)
    80004090:	02892503          	lw	a0,40(s2)
    80004094:	fffff097          	auipc	ra,0xfffff
    80004098:	ef4080e7          	jalr	-268(ra) # 80002f88 <bread>
    8000409c:	84aa                	mv	s1,a0
    memmove(dbuf->data, lbuf->data, BSIZE);  // copy block to dst
    8000409e:	40000613          	li	a2,1024
    800040a2:	058a8593          	addi	a1,s5,88
    800040a6:	05850513          	addi	a0,a0,88
    800040aa:	ffffd097          	auipc	ra,0xffffd
    800040ae:	d20080e7          	jalr	-736(ra) # 80000dca <memmove>
    bwrite(dbuf);  // write dst to disk
    800040b2:	8526                	mv	a0,s1
    800040b4:	fffff097          	auipc	ra,0xfffff
    800040b8:	fd8080e7          	jalr	-40(ra) # 8000308c <bwrite>
    bunpin(dbuf);
    800040bc:	8526                	mv	a0,s1
    800040be:	fffff097          	auipc	ra,0xfffff
    800040c2:	0e6080e7          	jalr	230(ra) # 800031a4 <bunpin>
    brelse(lbuf);
    800040c6:	8556                	mv	a0,s5
    800040c8:	fffff097          	auipc	ra,0xfffff
    800040cc:	002080e7          	jalr	2(ra) # 800030ca <brelse>
    brelse(dbuf);
    800040d0:	8526                	mv	a0,s1
    800040d2:	fffff097          	auipc	ra,0xfffff
    800040d6:	ff8080e7          	jalr	-8(ra) # 800030ca <brelse>
  for (tail = 0; tail < log.lh.n; tail++) {
    800040da:	2985                	addiw	s3,s3,1
    800040dc:	0a11                	addi	s4,s4,4
    800040de:	02c92783          	lw	a5,44(s2)
    800040e2:	f8f9c9e3          	blt	s3,a5,80004074 <install_trans+0x32>
}
    800040e6:	70e2                	ld	ra,56(sp)
    800040e8:	7442                	ld	s0,48(sp)
    800040ea:	74a2                	ld	s1,40(sp)
    800040ec:	7902                	ld	s2,32(sp)
    800040ee:	69e2                	ld	s3,24(sp)
    800040f0:	6a42                	ld	s4,16(sp)
    800040f2:	6aa2                	ld	s5,8(sp)
    800040f4:	6121                	addi	sp,sp,64
    800040f6:	8082                	ret
    800040f8:	8082                	ret

00000000800040fa <initlog>:
{
    800040fa:	7179                	addi	sp,sp,-48
    800040fc:	f406                	sd	ra,40(sp)
    800040fe:	f022                	sd	s0,32(sp)
    80004100:	ec26                	sd	s1,24(sp)
    80004102:	e84a                	sd	s2,16(sp)
    80004104:	e44e                	sd	s3,8(sp)
    80004106:	1800                	addi	s0,sp,48
    80004108:	892a                	mv	s2,a0
    8000410a:	89ae                	mv	s3,a1
  initlock(&log.lock, "log");
    8000410c:	0001d497          	auipc	s1,0x1d
    80004110:	7fc48493          	addi	s1,s1,2044 # 80021908 <log>
    80004114:	00004597          	auipc	a1,0x4
    80004118:	48458593          	addi	a1,a1,1156 # 80008598 <syscalls+0x200>
    8000411c:	8526                	mv	a0,s1
    8000411e:	ffffd097          	auipc	ra,0xffffd
    80004122:	ab4080e7          	jalr	-1356(ra) # 80000bd2 <initlock>
  log.start = sb->logstart;
    80004126:	0149a583          	lw	a1,20(s3)
    8000412a:	cc8c                	sw	a1,24(s1)
  log.size = sb->nlog;
    8000412c:	0109a783          	lw	a5,16(s3)
    80004130:	ccdc                	sw	a5,28(s1)
  log.dev = dev;
    80004132:	0324a423          	sw	s2,40(s1)
  struct buf *buf = bread(log.dev, log.start);
    80004136:	854a                	mv	a0,s2
    80004138:	fffff097          	auipc	ra,0xfffff
    8000413c:	e50080e7          	jalr	-432(ra) # 80002f88 <bread>
  log.lh.n = lh->n;
    80004140:	4d3c                	lw	a5,88(a0)
    80004142:	d4dc                	sw	a5,44(s1)
  for (i = 0; i < log.lh.n; i++) {
    80004144:	02f05563          	blez	a5,8000416e <initlog+0x74>
    80004148:	05c50713          	addi	a4,a0,92
    8000414c:	0001d697          	auipc	a3,0x1d
    80004150:	7ec68693          	addi	a3,a3,2028 # 80021938 <log+0x30>
    80004154:	37fd                	addiw	a5,a5,-1
    80004156:	1782                	slli	a5,a5,0x20
    80004158:	9381                	srli	a5,a5,0x20
    8000415a:	078a                	slli	a5,a5,0x2
    8000415c:	06050613          	addi	a2,a0,96
    80004160:	97b2                	add	a5,a5,a2
    log.lh.block[i] = lh->block[i];
    80004162:	4310                	lw	a2,0(a4)
    80004164:	c290                	sw	a2,0(a3)
  for (i = 0; i < log.lh.n; i++) {
    80004166:	0711                	addi	a4,a4,4
    80004168:	0691                	addi	a3,a3,4
    8000416a:	fef71ce3          	bne	a4,a5,80004162 <initlog+0x68>
  brelse(buf);
    8000416e:	fffff097          	auipc	ra,0xfffff
    80004172:	f5c080e7          	jalr	-164(ra) # 800030ca <brelse>

static void
recover_from_log(void)
{
  read_head();
  install_trans(); // if committed, copy from log to disk
    80004176:	00000097          	auipc	ra,0x0
    8000417a:	ecc080e7          	jalr	-308(ra) # 80004042 <install_trans>
  log.lh.n = 0;
    8000417e:	0001d797          	auipc	a5,0x1d
    80004182:	7a07ab23          	sw	zero,1974(a5) # 80021934 <log+0x2c>
  write_head(); // clear the log
    80004186:	00000097          	auipc	ra,0x0
    8000418a:	e42080e7          	jalr	-446(ra) # 80003fc8 <write_head>
}
    8000418e:	70a2                	ld	ra,40(sp)
    80004190:	7402                	ld	s0,32(sp)
    80004192:	64e2                	ld	s1,24(sp)
    80004194:	6942                	ld	s2,16(sp)
    80004196:	69a2                	ld	s3,8(sp)
    80004198:	6145                	addi	sp,sp,48
    8000419a:	8082                	ret

000000008000419c <begin_op>:
}

// called at the start of each FS system call.
void
begin_op(void)
{
    8000419c:	1101                	addi	sp,sp,-32
    8000419e:	ec06                	sd	ra,24(sp)
    800041a0:	e822                	sd	s0,16(sp)
    800041a2:	e426                	sd	s1,8(sp)
    800041a4:	e04a                	sd	s2,0(sp)
    800041a6:	1000                	addi	s0,sp,32
  acquire(&log.lock);
    800041a8:	0001d517          	auipc	a0,0x1d
    800041ac:	76050513          	addi	a0,a0,1888 # 80021908 <log>
    800041b0:	ffffd097          	auipc	ra,0xffffd
    800041b4:	ab2080e7          	jalr	-1358(ra) # 80000c62 <acquire>
  while(1){
    if(log.committing){
    800041b8:	0001d497          	auipc	s1,0x1d
    800041bc:	75048493          	addi	s1,s1,1872 # 80021908 <log>
      sleep(&log, &log.lock);
    } else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){
    800041c0:	4979                	li	s2,30
    800041c2:	a039                	j	800041d0 <begin_op+0x34>
      sleep(&log, &log.lock);
    800041c4:	85a6                	mv	a1,s1
    800041c6:	8526                	mv	a0,s1
    800041c8:	ffffe097          	auipc	ra,0xffffe
    800041cc:	0ea080e7          	jalr	234(ra) # 800022b2 <sleep>
    if(log.committing){
    800041d0:	50dc                	lw	a5,36(s1)
    800041d2:	fbed                	bnez	a5,800041c4 <begin_op+0x28>
    } else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){
    800041d4:	509c                	lw	a5,32(s1)
    800041d6:	0017871b          	addiw	a4,a5,1
    800041da:	0007069b          	sext.w	a3,a4
    800041de:	0027179b          	slliw	a5,a4,0x2
    800041e2:	9fb9                	addw	a5,a5,a4
    800041e4:	0017979b          	slliw	a5,a5,0x1
    800041e8:	54d8                	lw	a4,44(s1)
    800041ea:	9fb9                	addw	a5,a5,a4
    800041ec:	00f95963          	ble	a5,s2,800041fe <begin_op+0x62>
      // this op might exhaust log space; wait for commit.
      sleep(&log, &log.lock);
    800041f0:	85a6                	mv	a1,s1
    800041f2:	8526                	mv	a0,s1
    800041f4:	ffffe097          	auipc	ra,0xffffe
    800041f8:	0be080e7          	jalr	190(ra) # 800022b2 <sleep>
    800041fc:	bfd1                	j	800041d0 <begin_op+0x34>
    } else {
      log.outstanding += 1;
    800041fe:	0001d517          	auipc	a0,0x1d
    80004202:	70a50513          	addi	a0,a0,1802 # 80021908 <log>
    80004206:	d114                	sw	a3,32(a0)
      release(&log.lock);
    80004208:	ffffd097          	auipc	ra,0xffffd
    8000420c:	b0e080e7          	jalr	-1266(ra) # 80000d16 <release>
      break;
    }
  }
}
    80004210:	60e2                	ld	ra,24(sp)
    80004212:	6442                	ld	s0,16(sp)
    80004214:	64a2                	ld	s1,8(sp)
    80004216:	6902                	ld	s2,0(sp)
    80004218:	6105                	addi	sp,sp,32
    8000421a:	8082                	ret

000000008000421c <end_op>:

// called at the end of each FS system call.
// commits if this was the last outstanding operation.
void
end_op(void)
{
    8000421c:	7139                	addi	sp,sp,-64
    8000421e:	fc06                	sd	ra,56(sp)
    80004220:	f822                	sd	s0,48(sp)
    80004222:	f426                	sd	s1,40(sp)
    80004224:	f04a                	sd	s2,32(sp)
    80004226:	ec4e                	sd	s3,24(sp)
    80004228:	e852                	sd	s4,16(sp)
    8000422a:	e456                	sd	s5,8(sp)
    8000422c:	0080                	addi	s0,sp,64
  int do_commit = 0;

  acquire(&log.lock);
    8000422e:	0001d917          	auipc	s2,0x1d
    80004232:	6da90913          	addi	s2,s2,1754 # 80021908 <log>
    80004236:	854a                	mv	a0,s2
    80004238:	ffffd097          	auipc	ra,0xffffd
    8000423c:	a2a080e7          	jalr	-1494(ra) # 80000c62 <acquire>
  log.outstanding -= 1;
    80004240:	02092783          	lw	a5,32(s2)
    80004244:	37fd                	addiw	a5,a5,-1
    80004246:	0007849b          	sext.w	s1,a5
    8000424a:	02f92023          	sw	a5,32(s2)
  if(log.committing)
    8000424e:	02492783          	lw	a5,36(s2)
    80004252:	eba1                	bnez	a5,800042a2 <end_op+0x86>
    panic("log.committing");
  if(log.outstanding == 0){
    80004254:	ecb9                	bnez	s1,800042b2 <end_op+0x96>
    do_commit = 1;
    log.committing = 1;
    80004256:	0001d917          	auipc	s2,0x1d
    8000425a:	6b290913          	addi	s2,s2,1714 # 80021908 <log>
    8000425e:	4785                	li	a5,1
    80004260:	02f92223          	sw	a5,36(s2)
    // begin_op() may be waiting for log space,
    // and decrementing log.outstanding has decreased
    // the amount of reserved space.
    wakeup(&log);
  }
  release(&log.lock);
    80004264:	854a                	mv	a0,s2
    80004266:	ffffd097          	auipc	ra,0xffffd
    8000426a:	ab0080e7          	jalr	-1360(ra) # 80000d16 <release>
}

static void
commit()
{
  if (log.lh.n > 0) {
    8000426e:	02c92783          	lw	a5,44(s2)
    80004272:	06f04763          	bgtz	a5,800042e0 <end_op+0xc4>
    acquire(&log.lock);
    80004276:	0001d497          	auipc	s1,0x1d
    8000427a:	69248493          	addi	s1,s1,1682 # 80021908 <log>
    8000427e:	8526                	mv	a0,s1
    80004280:	ffffd097          	auipc	ra,0xffffd
    80004284:	9e2080e7          	jalr	-1566(ra) # 80000c62 <acquire>
    log.committing = 0;
    80004288:	0204a223          	sw	zero,36(s1)
    wakeup(&log);
    8000428c:	8526                	mv	a0,s1
    8000428e:	ffffe097          	auipc	ra,0xffffe
    80004292:	1aa080e7          	jalr	426(ra) # 80002438 <wakeup>
    release(&log.lock);
    80004296:	8526                	mv	a0,s1
    80004298:	ffffd097          	auipc	ra,0xffffd
    8000429c:	a7e080e7          	jalr	-1410(ra) # 80000d16 <release>
}
    800042a0:	a03d                	j	800042ce <end_op+0xb2>
    panic("log.committing");
    800042a2:	00004517          	auipc	a0,0x4
    800042a6:	2fe50513          	addi	a0,a0,766 # 800085a0 <syscalls+0x208>
    800042aa:	ffffc097          	auipc	ra,0xffffc
    800042ae:	2ca080e7          	jalr	714(ra) # 80000574 <panic>
    wakeup(&log);
    800042b2:	0001d497          	auipc	s1,0x1d
    800042b6:	65648493          	addi	s1,s1,1622 # 80021908 <log>
    800042ba:	8526                	mv	a0,s1
    800042bc:	ffffe097          	auipc	ra,0xffffe
    800042c0:	17c080e7          	jalr	380(ra) # 80002438 <wakeup>
  release(&log.lock);
    800042c4:	8526                	mv	a0,s1
    800042c6:	ffffd097          	auipc	ra,0xffffd
    800042ca:	a50080e7          	jalr	-1456(ra) # 80000d16 <release>
}
    800042ce:	70e2                	ld	ra,56(sp)
    800042d0:	7442                	ld	s0,48(sp)
    800042d2:	74a2                	ld	s1,40(sp)
    800042d4:	7902                	ld	s2,32(sp)
    800042d6:	69e2                	ld	s3,24(sp)
    800042d8:	6a42                	ld	s4,16(sp)
    800042da:	6aa2                	ld	s5,8(sp)
    800042dc:	6121                	addi	sp,sp,64
    800042de:	8082                	ret
    800042e0:	0001da17          	auipc	s4,0x1d
    800042e4:	658a0a13          	addi	s4,s4,1624 # 80021938 <log+0x30>
    struct buf *to = bread(log.dev, log.start+tail+1); // log block
    800042e8:	0001d917          	auipc	s2,0x1d
    800042ec:	62090913          	addi	s2,s2,1568 # 80021908 <log>
    800042f0:	01892583          	lw	a1,24(s2)
    800042f4:	9da5                	addw	a1,a1,s1
    800042f6:	2585                	addiw	a1,a1,1
    800042f8:	02892503          	lw	a0,40(s2)
    800042fc:	fffff097          	auipc	ra,0xfffff
    80004300:	c8c080e7          	jalr	-884(ra) # 80002f88 <bread>
    80004304:	89aa                	mv	s3,a0
    struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block
    80004306:	000a2583          	lw	a1,0(s4)
    8000430a:	02892503          	lw	a0,40(s2)
    8000430e:	fffff097          	auipc	ra,0xfffff
    80004312:	c7a080e7          	jalr	-902(ra) # 80002f88 <bread>
    80004316:	8aaa                	mv	s5,a0
    memmove(to->data, from->data, BSIZE);
    80004318:	40000613          	li	a2,1024
    8000431c:	05850593          	addi	a1,a0,88
    80004320:	05898513          	addi	a0,s3,88
    80004324:	ffffd097          	auipc	ra,0xffffd
    80004328:	aa6080e7          	jalr	-1370(ra) # 80000dca <memmove>
    bwrite(to);  // write the log
    8000432c:	854e                	mv	a0,s3
    8000432e:	fffff097          	auipc	ra,0xfffff
    80004332:	d5e080e7          	jalr	-674(ra) # 8000308c <bwrite>
    brelse(from);
    80004336:	8556                	mv	a0,s5
    80004338:	fffff097          	auipc	ra,0xfffff
    8000433c:	d92080e7          	jalr	-622(ra) # 800030ca <brelse>
    brelse(to);
    80004340:	854e                	mv	a0,s3
    80004342:	fffff097          	auipc	ra,0xfffff
    80004346:	d88080e7          	jalr	-632(ra) # 800030ca <brelse>
  for (tail = 0; tail < log.lh.n; tail++) {
    8000434a:	2485                	addiw	s1,s1,1
    8000434c:	0a11                	addi	s4,s4,4
    8000434e:	02c92783          	lw	a5,44(s2)
    80004352:	f8f4cfe3          	blt	s1,a5,800042f0 <end_op+0xd4>
    write_log();     // Write modified blocks from cache to log
    write_head();    // Write header to disk -- the real commit
    80004356:	00000097          	auipc	ra,0x0
    8000435a:	c72080e7          	jalr	-910(ra) # 80003fc8 <write_head>
    install_trans(); // Now install writes to home locations
    8000435e:	00000097          	auipc	ra,0x0
    80004362:	ce4080e7          	jalr	-796(ra) # 80004042 <install_trans>
    log.lh.n = 0;
    80004366:	0001d797          	auipc	a5,0x1d
    8000436a:	5c07a723          	sw	zero,1486(a5) # 80021934 <log+0x2c>
    write_head();    // Erase the transaction from the log
    8000436e:	00000097          	auipc	ra,0x0
    80004372:	c5a080e7          	jalr	-934(ra) # 80003fc8 <write_head>
    80004376:	b701                	j	80004276 <end_op+0x5a>

0000000080004378 <log_write>:
//   modify bp->data[]
//   log_write(bp)
//   brelse(bp)
void
log_write(struct buf *b)
{
    80004378:	1101                	addi	sp,sp,-32
    8000437a:	ec06                	sd	ra,24(sp)
    8000437c:	e822                	sd	s0,16(sp)
    8000437e:	e426                	sd	s1,8(sp)
    80004380:	e04a                	sd	s2,0(sp)
    80004382:	1000                	addi	s0,sp,32
  int i;

  if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1)
    80004384:	0001d797          	auipc	a5,0x1d
    80004388:	58478793          	addi	a5,a5,1412 # 80021908 <log>
    8000438c:	57d8                	lw	a4,44(a5)
    8000438e:	47f5                	li	a5,29
    80004390:	08e7c563          	blt	a5,a4,8000441a <log_write+0xa2>
    80004394:	892a                	mv	s2,a0
    80004396:	0001d797          	auipc	a5,0x1d
    8000439a:	57278793          	addi	a5,a5,1394 # 80021908 <log>
    8000439e:	4fdc                	lw	a5,28(a5)
    800043a0:	37fd                	addiw	a5,a5,-1
    800043a2:	06f75c63          	ble	a5,a4,8000441a <log_write+0xa2>
    panic("too big a transaction");
  if (log.outstanding < 1)
    800043a6:	0001d797          	auipc	a5,0x1d
    800043aa:	56278793          	addi	a5,a5,1378 # 80021908 <log>
    800043ae:	539c                	lw	a5,32(a5)
    800043b0:	06f05d63          	blez	a5,8000442a <log_write+0xb2>
    panic("log_write outside of trans");

  acquire(&log.lock);
    800043b4:	0001d497          	auipc	s1,0x1d
    800043b8:	55448493          	addi	s1,s1,1364 # 80021908 <log>
    800043bc:	8526                	mv	a0,s1
    800043be:	ffffd097          	auipc	ra,0xffffd
    800043c2:	8a4080e7          	jalr	-1884(ra) # 80000c62 <acquire>
  for (i = 0; i < log.lh.n; i++) {
    800043c6:	54d0                	lw	a2,44(s1)
    800043c8:	0ac05063          	blez	a2,80004468 <log_write+0xf0>
    if (log.lh.block[i] == b->blockno)   // log absorbtion
    800043cc:	00c92583          	lw	a1,12(s2)
    800043d0:	589c                	lw	a5,48(s1)
    800043d2:	0ab78363          	beq	a5,a1,80004478 <log_write+0x100>
    800043d6:	0001d717          	auipc	a4,0x1d
    800043da:	56670713          	addi	a4,a4,1382 # 8002193c <log+0x34>
  for (i = 0; i < log.lh.n; i++) {
    800043de:	4781                	li	a5,0
    800043e0:	2785                	addiw	a5,a5,1
    800043e2:	04c78c63          	beq	a5,a2,8000443a <log_write+0xc2>
    if (log.lh.block[i] == b->blockno)   // log absorbtion
    800043e6:	4314                	lw	a3,0(a4)
    800043e8:	0711                	addi	a4,a4,4
    800043ea:	feb69be3          	bne	a3,a1,800043e0 <log_write+0x68>
      break;
  }
  log.lh.block[i] = b->blockno;
    800043ee:	07a1                	addi	a5,a5,8
    800043f0:	078a                	slli	a5,a5,0x2
    800043f2:	0001d717          	auipc	a4,0x1d
    800043f6:	51670713          	addi	a4,a4,1302 # 80021908 <log>
    800043fa:	97ba                	add	a5,a5,a4
    800043fc:	cb8c                	sw	a1,16(a5)
  if (i == log.lh.n) {  // Add new block to log?
    bpin(b);
    log.lh.n++;
  }
  release(&log.lock);
    800043fe:	0001d517          	auipc	a0,0x1d
    80004402:	50a50513          	addi	a0,a0,1290 # 80021908 <log>
    80004406:	ffffd097          	auipc	ra,0xffffd
    8000440a:	910080e7          	jalr	-1776(ra) # 80000d16 <release>
}
    8000440e:	60e2                	ld	ra,24(sp)
    80004410:	6442                	ld	s0,16(sp)
    80004412:	64a2                	ld	s1,8(sp)
    80004414:	6902                	ld	s2,0(sp)
    80004416:	6105                	addi	sp,sp,32
    80004418:	8082                	ret
    panic("too big a transaction");
    8000441a:	00004517          	auipc	a0,0x4
    8000441e:	19650513          	addi	a0,a0,406 # 800085b0 <syscalls+0x218>
    80004422:	ffffc097          	auipc	ra,0xffffc
    80004426:	152080e7          	jalr	338(ra) # 80000574 <panic>
    panic("log_write outside of trans");
    8000442a:	00004517          	auipc	a0,0x4
    8000442e:	19e50513          	addi	a0,a0,414 # 800085c8 <syscalls+0x230>
    80004432:	ffffc097          	auipc	ra,0xffffc
    80004436:	142080e7          	jalr	322(ra) # 80000574 <panic>
  log.lh.block[i] = b->blockno;
    8000443a:	0621                	addi	a2,a2,8
    8000443c:	060a                	slli	a2,a2,0x2
    8000443e:	0001d797          	auipc	a5,0x1d
    80004442:	4ca78793          	addi	a5,a5,1226 # 80021908 <log>
    80004446:	963e                	add	a2,a2,a5
    80004448:	00c92783          	lw	a5,12(s2)
    8000444c:	ca1c                	sw	a5,16(a2)
    bpin(b);
    8000444e:	854a                	mv	a0,s2
    80004450:	fffff097          	auipc	ra,0xfffff
    80004454:	d18080e7          	jalr	-744(ra) # 80003168 <bpin>
    log.lh.n++;
    80004458:	0001d717          	auipc	a4,0x1d
    8000445c:	4b070713          	addi	a4,a4,1200 # 80021908 <log>
    80004460:	575c                	lw	a5,44(a4)
    80004462:	2785                	addiw	a5,a5,1
    80004464:	d75c                	sw	a5,44(a4)
    80004466:	bf61                	j	800043fe <log_write+0x86>
  log.lh.block[i] = b->blockno;
    80004468:	00c92783          	lw	a5,12(s2)
    8000446c:	0001d717          	auipc	a4,0x1d
    80004470:	4cf72623          	sw	a5,1228(a4) # 80021938 <log+0x30>
  if (i == log.lh.n) {  // Add new block to log?
    80004474:	f649                	bnez	a2,800043fe <log_write+0x86>
    80004476:	bfe1                	j	8000444e <log_write+0xd6>
  for (i = 0; i < log.lh.n; i++) {
    80004478:	4781                	li	a5,0
    8000447a:	bf95                	j	800043ee <log_write+0x76>

000000008000447c <initsleeplock>:
#include "proc.h"
#include "sleeplock.h"

void
initsleeplock(struct sleeplock *lk, char *name)
{
    8000447c:	1101                	addi	sp,sp,-32
    8000447e:	ec06                	sd	ra,24(sp)
    80004480:	e822                	sd	s0,16(sp)
    80004482:	e426                	sd	s1,8(sp)
    80004484:	e04a                	sd	s2,0(sp)
    80004486:	1000                	addi	s0,sp,32
    80004488:	84aa                	mv	s1,a0
    8000448a:	892e                	mv	s2,a1
  initlock(&lk->lk, "sleep lock");
    8000448c:	00004597          	auipc	a1,0x4
    80004490:	15c58593          	addi	a1,a1,348 # 800085e8 <syscalls+0x250>
    80004494:	0521                	addi	a0,a0,8
    80004496:	ffffc097          	auipc	ra,0xffffc
    8000449a:	73c080e7          	jalr	1852(ra) # 80000bd2 <initlock>
  lk->name = name;
    8000449e:	0324b023          	sd	s2,32(s1)
  lk->locked = 0;
    800044a2:	0004a023          	sw	zero,0(s1)
  lk->pid = 0;
    800044a6:	0204a423          	sw	zero,40(s1)
}
    800044aa:	60e2                	ld	ra,24(sp)
    800044ac:	6442                	ld	s0,16(sp)
    800044ae:	64a2                	ld	s1,8(sp)
    800044b0:	6902                	ld	s2,0(sp)
    800044b2:	6105                	addi	sp,sp,32
    800044b4:	8082                	ret

00000000800044b6 <acquiresleep>:

void
acquiresleep(struct sleeplock *lk)
{
    800044b6:	1101                	addi	sp,sp,-32
    800044b8:	ec06                	sd	ra,24(sp)
    800044ba:	e822                	sd	s0,16(sp)
    800044bc:	e426                	sd	s1,8(sp)
    800044be:	e04a                	sd	s2,0(sp)
    800044c0:	1000                	addi	s0,sp,32
    800044c2:	84aa                	mv	s1,a0
  acquire(&lk->lk);
    800044c4:	00850913          	addi	s2,a0,8
    800044c8:	854a                	mv	a0,s2
    800044ca:	ffffc097          	auipc	ra,0xffffc
    800044ce:	798080e7          	jalr	1944(ra) # 80000c62 <acquire>
  while (lk->locked) {
    800044d2:	409c                	lw	a5,0(s1)
    800044d4:	cb89                	beqz	a5,800044e6 <acquiresleep+0x30>
    sleep(lk, &lk->lk);
    800044d6:	85ca                	mv	a1,s2
    800044d8:	8526                	mv	a0,s1
    800044da:	ffffe097          	auipc	ra,0xffffe
    800044de:	dd8080e7          	jalr	-552(ra) # 800022b2 <sleep>
  while (lk->locked) {
    800044e2:	409c                	lw	a5,0(s1)
    800044e4:	fbed                	bnez	a5,800044d6 <acquiresleep+0x20>
  }
  lk->locked = 1;
    800044e6:	4785                	li	a5,1
    800044e8:	c09c                	sw	a5,0(s1)
  lk->pid = myproc()->pid;
    800044ea:	ffffd097          	auipc	ra,0xffffd
    800044ee:	5ae080e7          	jalr	1454(ra) # 80001a98 <myproc>
    800044f2:	5d1c                	lw	a5,56(a0)
    800044f4:	d49c                	sw	a5,40(s1)
  release(&lk->lk);
    800044f6:	854a                	mv	a0,s2
    800044f8:	ffffd097          	auipc	ra,0xffffd
    800044fc:	81e080e7          	jalr	-2018(ra) # 80000d16 <release>
}
    80004500:	60e2                	ld	ra,24(sp)
    80004502:	6442                	ld	s0,16(sp)
    80004504:	64a2                	ld	s1,8(sp)
    80004506:	6902                	ld	s2,0(sp)
    80004508:	6105                	addi	sp,sp,32
    8000450a:	8082                	ret

000000008000450c <releasesleep>:

void
releasesleep(struct sleeplock *lk)
{
    8000450c:	1101                	addi	sp,sp,-32
    8000450e:	ec06                	sd	ra,24(sp)
    80004510:	e822                	sd	s0,16(sp)
    80004512:	e426                	sd	s1,8(sp)
    80004514:	e04a                	sd	s2,0(sp)
    80004516:	1000                	addi	s0,sp,32
    80004518:	84aa                	mv	s1,a0
  acquire(&lk->lk);
    8000451a:	00850913          	addi	s2,a0,8
    8000451e:	854a                	mv	a0,s2
    80004520:	ffffc097          	auipc	ra,0xffffc
    80004524:	742080e7          	jalr	1858(ra) # 80000c62 <acquire>
  lk->locked = 0;
    80004528:	0004a023          	sw	zero,0(s1)
  lk->pid = 0;
    8000452c:	0204a423          	sw	zero,40(s1)
  wakeup(lk);
    80004530:	8526                	mv	a0,s1
    80004532:	ffffe097          	auipc	ra,0xffffe
    80004536:	f06080e7          	jalr	-250(ra) # 80002438 <wakeup>
  release(&lk->lk);
    8000453a:	854a                	mv	a0,s2
    8000453c:	ffffc097          	auipc	ra,0xffffc
    80004540:	7da080e7          	jalr	2010(ra) # 80000d16 <release>
}
    80004544:	60e2                	ld	ra,24(sp)
    80004546:	6442                	ld	s0,16(sp)
    80004548:	64a2                	ld	s1,8(sp)
    8000454a:	6902                	ld	s2,0(sp)
    8000454c:	6105                	addi	sp,sp,32
    8000454e:	8082                	ret

0000000080004550 <holdingsleep>:

int
holdingsleep(struct sleeplock *lk)
{
    80004550:	7179                	addi	sp,sp,-48
    80004552:	f406                	sd	ra,40(sp)
    80004554:	f022                	sd	s0,32(sp)
    80004556:	ec26                	sd	s1,24(sp)
    80004558:	e84a                	sd	s2,16(sp)
    8000455a:	e44e                	sd	s3,8(sp)
    8000455c:	1800                	addi	s0,sp,48
    8000455e:	84aa                	mv	s1,a0
  int r;
  
  acquire(&lk->lk);
    80004560:	00850913          	addi	s2,a0,8
    80004564:	854a                	mv	a0,s2
    80004566:	ffffc097          	auipc	ra,0xffffc
    8000456a:	6fc080e7          	jalr	1788(ra) # 80000c62 <acquire>
  r = lk->locked && (lk->pid == myproc()->pid);
    8000456e:	409c                	lw	a5,0(s1)
    80004570:	ef99                	bnez	a5,8000458e <holdingsleep+0x3e>
    80004572:	4481                	li	s1,0
  release(&lk->lk);
    80004574:	854a                	mv	a0,s2
    80004576:	ffffc097          	auipc	ra,0xffffc
    8000457a:	7a0080e7          	jalr	1952(ra) # 80000d16 <release>
  return r;
}
    8000457e:	8526                	mv	a0,s1
    80004580:	70a2                	ld	ra,40(sp)
    80004582:	7402                	ld	s0,32(sp)
    80004584:	64e2                	ld	s1,24(sp)
    80004586:	6942                	ld	s2,16(sp)
    80004588:	69a2                	ld	s3,8(sp)
    8000458a:	6145                	addi	sp,sp,48
    8000458c:	8082                	ret
  r = lk->locked && (lk->pid == myproc()->pid);
    8000458e:	0284a983          	lw	s3,40(s1)
    80004592:	ffffd097          	auipc	ra,0xffffd
    80004596:	506080e7          	jalr	1286(ra) # 80001a98 <myproc>
    8000459a:	5d04                	lw	s1,56(a0)
    8000459c:	413484b3          	sub	s1,s1,s3
    800045a0:	0014b493          	seqz	s1,s1
    800045a4:	bfc1                	j	80004574 <holdingsleep+0x24>

00000000800045a6 <fileinit>:
  struct file file[NFILE];
} ftable;

void
fileinit(void)
{
    800045a6:	1141                	addi	sp,sp,-16
    800045a8:	e406                	sd	ra,8(sp)
    800045aa:	e022                	sd	s0,0(sp)
    800045ac:	0800                	addi	s0,sp,16
  initlock(&ftable.lock, "ftable");
    800045ae:	00004597          	auipc	a1,0x4
    800045b2:	04a58593          	addi	a1,a1,74 # 800085f8 <syscalls+0x260>
    800045b6:	0001d517          	auipc	a0,0x1d
    800045ba:	49a50513          	addi	a0,a0,1178 # 80021a50 <ftable>
    800045be:	ffffc097          	auipc	ra,0xffffc
    800045c2:	614080e7          	jalr	1556(ra) # 80000bd2 <initlock>
}
    800045c6:	60a2                	ld	ra,8(sp)
    800045c8:	6402                	ld	s0,0(sp)
    800045ca:	0141                	addi	sp,sp,16
    800045cc:	8082                	ret

00000000800045ce <filealloc>:

// Allocate a file structure.
struct file*
filealloc(void)
{
    800045ce:	1101                	addi	sp,sp,-32
    800045d0:	ec06                	sd	ra,24(sp)
    800045d2:	e822                	sd	s0,16(sp)
    800045d4:	e426                	sd	s1,8(sp)
    800045d6:	1000                	addi	s0,sp,32
  struct file *f;

  acquire(&ftable.lock);
    800045d8:	0001d517          	auipc	a0,0x1d
    800045dc:	47850513          	addi	a0,a0,1144 # 80021a50 <ftable>
    800045e0:	ffffc097          	auipc	ra,0xffffc
    800045e4:	682080e7          	jalr	1666(ra) # 80000c62 <acquire>
  for(f = ftable.file; f < ftable.file + NFILE; f++){
    if(f->ref == 0){
    800045e8:	0001d797          	auipc	a5,0x1d
    800045ec:	46878793          	addi	a5,a5,1128 # 80021a50 <ftable>
    800045f0:	4fdc                	lw	a5,28(a5)
    800045f2:	cb8d                	beqz	a5,80004624 <filealloc+0x56>
  for(f = ftable.file; f < ftable.file + NFILE; f++){
    800045f4:	0001d497          	auipc	s1,0x1d
    800045f8:	49c48493          	addi	s1,s1,1180 # 80021a90 <ftable+0x40>
    800045fc:	0001e717          	auipc	a4,0x1e
    80004600:	40c70713          	addi	a4,a4,1036 # 80022a08 <ftable+0xfb8>
    if(f->ref == 0){
    80004604:	40dc                	lw	a5,4(s1)
    80004606:	c39d                	beqz	a5,8000462c <filealloc+0x5e>
  for(f = ftable.file; f < ftable.file + NFILE; f++){
    80004608:	02848493          	addi	s1,s1,40
    8000460c:	fee49ce3          	bne	s1,a4,80004604 <filealloc+0x36>
      f->ref = 1;
      release(&ftable.lock);
      return f;
    }
  }
  release(&ftable.lock);
    80004610:	0001d517          	auipc	a0,0x1d
    80004614:	44050513          	addi	a0,a0,1088 # 80021a50 <ftable>
    80004618:	ffffc097          	auipc	ra,0xffffc
    8000461c:	6fe080e7          	jalr	1790(ra) # 80000d16 <release>
  return 0;
    80004620:	4481                	li	s1,0
    80004622:	a839                	j	80004640 <filealloc+0x72>
  for(f = ftable.file; f < ftable.file + NFILE; f++){
    80004624:	0001d497          	auipc	s1,0x1d
    80004628:	44448493          	addi	s1,s1,1092 # 80021a68 <ftable+0x18>
      f->ref = 1;
    8000462c:	4785                	li	a5,1
    8000462e:	c0dc                	sw	a5,4(s1)
      release(&ftable.lock);
    80004630:	0001d517          	auipc	a0,0x1d
    80004634:	42050513          	addi	a0,a0,1056 # 80021a50 <ftable>
    80004638:	ffffc097          	auipc	ra,0xffffc
    8000463c:	6de080e7          	jalr	1758(ra) # 80000d16 <release>
}
    80004640:	8526                	mv	a0,s1
    80004642:	60e2                	ld	ra,24(sp)
    80004644:	6442                	ld	s0,16(sp)
    80004646:	64a2                	ld	s1,8(sp)
    80004648:	6105                	addi	sp,sp,32
    8000464a:	8082                	ret

000000008000464c <filedup>:

// Increment ref count for file f.
struct file*
filedup(struct file *f)
{
    8000464c:	1101                	addi	sp,sp,-32
    8000464e:	ec06                	sd	ra,24(sp)
    80004650:	e822                	sd	s0,16(sp)
    80004652:	e426                	sd	s1,8(sp)
    80004654:	1000                	addi	s0,sp,32
    80004656:	84aa                	mv	s1,a0
  acquire(&ftable.lock);
    80004658:	0001d517          	auipc	a0,0x1d
    8000465c:	3f850513          	addi	a0,a0,1016 # 80021a50 <ftable>
    80004660:	ffffc097          	auipc	ra,0xffffc
    80004664:	602080e7          	jalr	1538(ra) # 80000c62 <acquire>
  if(f->ref < 1)
    80004668:	40dc                	lw	a5,4(s1)
    8000466a:	02f05263          	blez	a5,8000468e <filedup+0x42>
    panic("filedup");
  f->ref++;
    8000466e:	2785                	addiw	a5,a5,1
    80004670:	c0dc                	sw	a5,4(s1)
  release(&ftable.lock);
    80004672:	0001d517          	auipc	a0,0x1d
    80004676:	3de50513          	addi	a0,a0,990 # 80021a50 <ftable>
    8000467a:	ffffc097          	auipc	ra,0xffffc
    8000467e:	69c080e7          	jalr	1692(ra) # 80000d16 <release>
  return f;
}
    80004682:	8526                	mv	a0,s1
    80004684:	60e2                	ld	ra,24(sp)
    80004686:	6442                	ld	s0,16(sp)
    80004688:	64a2                	ld	s1,8(sp)
    8000468a:	6105                	addi	sp,sp,32
    8000468c:	8082                	ret
    panic("filedup");
    8000468e:	00004517          	auipc	a0,0x4
    80004692:	f7250513          	addi	a0,a0,-142 # 80008600 <syscalls+0x268>
    80004696:	ffffc097          	auipc	ra,0xffffc
    8000469a:	ede080e7          	jalr	-290(ra) # 80000574 <panic>

000000008000469e <fileclose>:

// Close file f.  (Decrement ref count, close when reaches 0.)
void
fileclose(struct file *f)
{
    8000469e:	7139                	addi	sp,sp,-64
    800046a0:	fc06                	sd	ra,56(sp)
    800046a2:	f822                	sd	s0,48(sp)
    800046a4:	f426                	sd	s1,40(sp)
    800046a6:	f04a                	sd	s2,32(sp)
    800046a8:	ec4e                	sd	s3,24(sp)
    800046aa:	e852                	sd	s4,16(sp)
    800046ac:	e456                	sd	s5,8(sp)
    800046ae:	0080                	addi	s0,sp,64
    800046b0:	84aa                	mv	s1,a0
  struct file ff;

  acquire(&ftable.lock);
    800046b2:	0001d517          	auipc	a0,0x1d
    800046b6:	39e50513          	addi	a0,a0,926 # 80021a50 <ftable>
    800046ba:	ffffc097          	auipc	ra,0xffffc
    800046be:	5a8080e7          	jalr	1448(ra) # 80000c62 <acquire>
  if(f->ref < 1)
    800046c2:	40dc                	lw	a5,4(s1)
    800046c4:	06f05163          	blez	a5,80004726 <fileclose+0x88>
    panic("fileclose");
  if(--f->ref > 0){
    800046c8:	37fd                	addiw	a5,a5,-1
    800046ca:	0007871b          	sext.w	a4,a5
    800046ce:	c0dc                	sw	a5,4(s1)
    800046d0:	06e04363          	bgtz	a4,80004736 <fileclose+0x98>
    release(&ftable.lock);
    return;
  }
  ff = *f;
    800046d4:	0004a903          	lw	s2,0(s1)
    800046d8:	0094ca83          	lbu	s5,9(s1)
    800046dc:	0104ba03          	ld	s4,16(s1)
    800046e0:	0184b983          	ld	s3,24(s1)
  f->ref = 0;
    800046e4:	0004a223          	sw	zero,4(s1)
  f->type = FD_NONE;
    800046e8:	0004a023          	sw	zero,0(s1)
  release(&ftable.lock);
    800046ec:	0001d517          	auipc	a0,0x1d
    800046f0:	36450513          	addi	a0,a0,868 # 80021a50 <ftable>
    800046f4:	ffffc097          	auipc	ra,0xffffc
    800046f8:	622080e7          	jalr	1570(ra) # 80000d16 <release>

  if(ff.type == FD_PIPE){
    800046fc:	4785                	li	a5,1
    800046fe:	04f90d63          	beq	s2,a5,80004758 <fileclose+0xba>
    pipeclose(ff.pipe, ff.writable);
  } else if(ff.type == FD_INODE || ff.type == FD_DEVICE){
    80004702:	3979                	addiw	s2,s2,-2
    80004704:	4785                	li	a5,1
    80004706:	0527e063          	bltu	a5,s2,80004746 <fileclose+0xa8>
    begin_op();
    8000470a:	00000097          	auipc	ra,0x0
    8000470e:	a92080e7          	jalr	-1390(ra) # 8000419c <begin_op>
    iput(ff.ip);
    80004712:	854e                	mv	a0,s3
    80004714:	fffff097          	auipc	ra,0xfffff
    80004718:	278080e7          	jalr	632(ra) # 8000398c <iput>
    end_op();
    8000471c:	00000097          	auipc	ra,0x0
    80004720:	b00080e7          	jalr	-1280(ra) # 8000421c <end_op>
    80004724:	a00d                	j	80004746 <fileclose+0xa8>
    panic("fileclose");
    80004726:	00004517          	auipc	a0,0x4
    8000472a:	ee250513          	addi	a0,a0,-286 # 80008608 <syscalls+0x270>
    8000472e:	ffffc097          	auipc	ra,0xffffc
    80004732:	e46080e7          	jalr	-442(ra) # 80000574 <panic>
    release(&ftable.lock);
    80004736:	0001d517          	auipc	a0,0x1d
    8000473a:	31a50513          	addi	a0,a0,794 # 80021a50 <ftable>
    8000473e:	ffffc097          	auipc	ra,0xffffc
    80004742:	5d8080e7          	jalr	1496(ra) # 80000d16 <release>
  }
}
    80004746:	70e2                	ld	ra,56(sp)
    80004748:	7442                	ld	s0,48(sp)
    8000474a:	74a2                	ld	s1,40(sp)
    8000474c:	7902                	ld	s2,32(sp)
    8000474e:	69e2                	ld	s3,24(sp)
    80004750:	6a42                	ld	s4,16(sp)
    80004752:	6aa2                	ld	s5,8(sp)
    80004754:	6121                	addi	sp,sp,64
    80004756:	8082                	ret
    pipeclose(ff.pipe, ff.writable);
    80004758:	85d6                	mv	a1,s5
    8000475a:	8552                	mv	a0,s4
    8000475c:	00000097          	auipc	ra,0x0
    80004760:	364080e7          	jalr	868(ra) # 80004ac0 <pipeclose>
    80004764:	b7cd                	j	80004746 <fileclose+0xa8>

0000000080004766 <filestat>:

// Get metadata about file f.
// addr is a user virtual address, pointing to a struct stat.
int
filestat(struct file *f, uint64 addr)
{
    80004766:	715d                	addi	sp,sp,-80
    80004768:	e486                	sd	ra,72(sp)
    8000476a:	e0a2                	sd	s0,64(sp)
    8000476c:	fc26                	sd	s1,56(sp)
    8000476e:	f84a                	sd	s2,48(sp)
    80004770:	f44e                	sd	s3,40(sp)
    80004772:	0880                	addi	s0,sp,80
    80004774:	84aa                	mv	s1,a0
    80004776:	89ae                	mv	s3,a1
  struct proc *p = myproc();
    80004778:	ffffd097          	auipc	ra,0xffffd
    8000477c:	320080e7          	jalr	800(ra) # 80001a98 <myproc>
  struct stat st;
  
  if(f->type == FD_INODE || f->type == FD_DEVICE){
    80004780:	409c                	lw	a5,0(s1)
    80004782:	37f9                	addiw	a5,a5,-2
    80004784:	4705                	li	a4,1
    80004786:	04f76763          	bltu	a4,a5,800047d4 <filestat+0x6e>
    8000478a:	892a                	mv	s2,a0
    ilock(f->ip);
    8000478c:	6c88                	ld	a0,24(s1)
    8000478e:	fffff097          	auipc	ra,0xfffff
    80004792:	042080e7          	jalr	66(ra) # 800037d0 <ilock>
    stati(f->ip, &st);
    80004796:	fb840593          	addi	a1,s0,-72
    8000479a:	6c88                	ld	a0,24(s1)
    8000479c:	fffff097          	auipc	ra,0xfffff
    800047a0:	2c0080e7          	jalr	704(ra) # 80003a5c <stati>
    iunlock(f->ip);
    800047a4:	6c88                	ld	a0,24(s1)
    800047a6:	fffff097          	auipc	ra,0xfffff
    800047aa:	0ee080e7          	jalr	238(ra) # 80003894 <iunlock>
    if(copyout(p->pagetable, addr, (char *)&st, sizeof(st)) < 0)
    800047ae:	46e1                	li	a3,24
    800047b0:	fb840613          	addi	a2,s0,-72
    800047b4:	85ce                	mv	a1,s3
    800047b6:	05093503          	ld	a0,80(s2)
    800047ba:	ffffd097          	auipc	ra,0xffffd
    800047be:	fba080e7          	jalr	-70(ra) # 80001774 <copyout>
    800047c2:	41f5551b          	sraiw	a0,a0,0x1f
      return -1;
    return 0;
  }
  return -1;
}
    800047c6:	60a6                	ld	ra,72(sp)
    800047c8:	6406                	ld	s0,64(sp)
    800047ca:	74e2                	ld	s1,56(sp)
    800047cc:	7942                	ld	s2,48(sp)
    800047ce:	79a2                	ld	s3,40(sp)
    800047d0:	6161                	addi	sp,sp,80
    800047d2:	8082                	ret
  return -1;
    800047d4:	557d                	li	a0,-1
    800047d6:	bfc5                	j	800047c6 <filestat+0x60>

00000000800047d8 <fileread>:

// Read from file f.
// addr is a user virtual address.
int
fileread(struct file *f, uint64 addr, int n)
{
    800047d8:	7179                	addi	sp,sp,-48
    800047da:	f406                	sd	ra,40(sp)
    800047dc:	f022                	sd	s0,32(sp)
    800047de:	ec26                	sd	s1,24(sp)
    800047e0:	e84a                	sd	s2,16(sp)
    800047e2:	e44e                	sd	s3,8(sp)
    800047e4:	1800                	addi	s0,sp,48
  int r = 0;

  if(f->readable == 0)
    800047e6:	00854783          	lbu	a5,8(a0)
    800047ea:	c3d5                	beqz	a5,8000488e <fileread+0xb6>
    800047ec:	89b2                	mv	s3,a2
    800047ee:	892e                	mv	s2,a1
    800047f0:	84aa                	mv	s1,a0
    return -1;

  if(f->type == FD_PIPE){
    800047f2:	411c                	lw	a5,0(a0)
    800047f4:	4705                	li	a4,1
    800047f6:	04e78963          	beq	a5,a4,80004848 <fileread+0x70>
    r = piperead(f->pipe, addr, n);
  } else if(f->type == FD_DEVICE){
    800047fa:	470d                	li	a4,3
    800047fc:	04e78d63          	beq	a5,a4,80004856 <fileread+0x7e>
    if(f->major < 0 || f->major >= NDEV || !devsw[f->major].read)
      return -1;
    r = devsw[f->major].read(1, addr, n);
  } else if(f->type == FD_INODE){
    80004800:	4709                	li	a4,2
    80004802:	06e79e63          	bne	a5,a4,8000487e <fileread+0xa6>
    ilock(f->ip);
    80004806:	6d08                	ld	a0,24(a0)
    80004808:	fffff097          	auipc	ra,0xfffff
    8000480c:	fc8080e7          	jalr	-56(ra) # 800037d0 <ilock>
    if((r = readi(f->ip, 1, addr, f->off, n)) > 0)
    80004810:	874e                	mv	a4,s3
    80004812:	5094                	lw	a3,32(s1)
    80004814:	864a                	mv	a2,s2
    80004816:	4585                	li	a1,1
    80004818:	6c88                	ld	a0,24(s1)
    8000481a:	fffff097          	auipc	ra,0xfffff
    8000481e:	26c080e7          	jalr	620(ra) # 80003a86 <readi>
    80004822:	892a                	mv	s2,a0
    80004824:	00a05563          	blez	a0,8000482e <fileread+0x56>
      f->off += r;
    80004828:	509c                	lw	a5,32(s1)
    8000482a:	9fa9                	addw	a5,a5,a0
    8000482c:	d09c                	sw	a5,32(s1)
    iunlock(f->ip);
    8000482e:	6c88                	ld	a0,24(s1)
    80004830:	fffff097          	auipc	ra,0xfffff
    80004834:	064080e7          	jalr	100(ra) # 80003894 <iunlock>
  } else {
    panic("fileread");
  }

  return r;
}
    80004838:	854a                	mv	a0,s2
    8000483a:	70a2                	ld	ra,40(sp)
    8000483c:	7402                	ld	s0,32(sp)
    8000483e:	64e2                	ld	s1,24(sp)
    80004840:	6942                	ld	s2,16(sp)
    80004842:	69a2                	ld	s3,8(sp)
    80004844:	6145                	addi	sp,sp,48
    80004846:	8082                	ret
    r = piperead(f->pipe, addr, n);
    80004848:	6908                	ld	a0,16(a0)
    8000484a:	00000097          	auipc	ra,0x0
    8000484e:	416080e7          	jalr	1046(ra) # 80004c60 <piperead>
    80004852:	892a                	mv	s2,a0
    80004854:	b7d5                	j	80004838 <fileread+0x60>
    if(f->major < 0 || f->major >= NDEV || !devsw[f->major].read)
    80004856:	02451783          	lh	a5,36(a0)
    8000485a:	03079693          	slli	a3,a5,0x30
    8000485e:	92c1                	srli	a3,a3,0x30
    80004860:	4725                	li	a4,9
    80004862:	02d76863          	bltu	a4,a3,80004892 <fileread+0xba>
    80004866:	0792                	slli	a5,a5,0x4
    80004868:	0001d717          	auipc	a4,0x1d
    8000486c:	14870713          	addi	a4,a4,328 # 800219b0 <devsw>
    80004870:	97ba                	add	a5,a5,a4
    80004872:	639c                	ld	a5,0(a5)
    80004874:	c38d                	beqz	a5,80004896 <fileread+0xbe>
    r = devsw[f->major].read(1, addr, n);
    80004876:	4505                	li	a0,1
    80004878:	9782                	jalr	a5
    8000487a:	892a                	mv	s2,a0
    8000487c:	bf75                	j	80004838 <fileread+0x60>
    panic("fileread");
    8000487e:	00004517          	auipc	a0,0x4
    80004882:	d9a50513          	addi	a0,a0,-614 # 80008618 <syscalls+0x280>
    80004886:	ffffc097          	auipc	ra,0xffffc
    8000488a:	cee080e7          	jalr	-786(ra) # 80000574 <panic>
    return -1;
    8000488e:	597d                	li	s2,-1
    80004890:	b765                	j	80004838 <fileread+0x60>
      return -1;
    80004892:	597d                	li	s2,-1
    80004894:	b755                	j	80004838 <fileread+0x60>
    80004896:	597d                	li	s2,-1
    80004898:	b745                	j	80004838 <fileread+0x60>

000000008000489a <filewrite>:
int
filewrite(struct file *f, uint64 addr, int n)
{
  int r, ret = 0;

  if(f->writable == 0)
    8000489a:	00954783          	lbu	a5,9(a0)
    8000489e:	12078e63          	beqz	a5,800049da <filewrite+0x140>
{
    800048a2:	715d                	addi	sp,sp,-80
    800048a4:	e486                	sd	ra,72(sp)
    800048a6:	e0a2                	sd	s0,64(sp)
    800048a8:	fc26                	sd	s1,56(sp)
    800048aa:	f84a                	sd	s2,48(sp)
    800048ac:	f44e                	sd	s3,40(sp)
    800048ae:	f052                	sd	s4,32(sp)
    800048b0:	ec56                	sd	s5,24(sp)
    800048b2:	e85a                	sd	s6,16(sp)
    800048b4:	e45e                	sd	s7,8(sp)
    800048b6:	e062                	sd	s8,0(sp)
    800048b8:	0880                	addi	s0,sp,80
    800048ba:	8ab2                	mv	s5,a2
    800048bc:	8b2e                	mv	s6,a1
    800048be:	84aa                	mv	s1,a0
    return -1;

  if(f->type == FD_PIPE){
    800048c0:	411c                	lw	a5,0(a0)
    800048c2:	4705                	li	a4,1
    800048c4:	02e78263          	beq	a5,a4,800048e8 <filewrite+0x4e>
    ret = pipewrite(f->pipe, addr, n);
  } else if(f->type == FD_DEVICE){
    800048c8:	470d                	li	a4,3
    800048ca:	02e78563          	beq	a5,a4,800048f4 <filewrite+0x5a>
    if(f->major < 0 || f->major >= NDEV || !devsw[f->major].write)
      return -1;
    ret = devsw[f->major].write(1, addr, n);
  } else if(f->type == FD_INODE){
    800048ce:	4709                	li	a4,2
    800048d0:	0ee79d63          	bne	a5,a4,800049ca <filewrite+0x130>
    // and 2 blocks of slop for non-aligned writes.
    // this really belongs lower down, since writei()
    // might be writing a device like the console.
    int max = ((MAXOPBLOCKS-1-1-2) / 2) * BSIZE;
    int i = 0;
    while(i < n){
    800048d4:	0ec05763          	blez	a2,800049c2 <filewrite+0x128>
    int i = 0;
    800048d8:	4901                	li	s2,0
    800048da:	6b85                	lui	s7,0x1
    800048dc:	c00b8b93          	addi	s7,s7,-1024 # c00 <_entry-0x7ffff400>
    800048e0:	6c05                	lui	s8,0x1
    800048e2:	c00c0c1b          	addiw	s8,s8,-1024
    800048e6:	a061                	j	8000496e <filewrite+0xd4>
    ret = pipewrite(f->pipe, addr, n);
    800048e8:	6908                	ld	a0,16(a0)
    800048ea:	00000097          	auipc	ra,0x0
    800048ee:	246080e7          	jalr	582(ra) # 80004b30 <pipewrite>
    800048f2:	a065                	j	8000499a <filewrite+0x100>
    if(f->major < 0 || f->major >= NDEV || !devsw[f->major].write)
    800048f4:	02451783          	lh	a5,36(a0)
    800048f8:	03079693          	slli	a3,a5,0x30
    800048fc:	92c1                	srli	a3,a3,0x30
    800048fe:	4725                	li	a4,9
    80004900:	0cd76f63          	bltu	a4,a3,800049de <filewrite+0x144>
    80004904:	0792                	slli	a5,a5,0x4
    80004906:	0001d717          	auipc	a4,0x1d
    8000490a:	0aa70713          	addi	a4,a4,170 # 800219b0 <devsw>
    8000490e:	97ba                	add	a5,a5,a4
    80004910:	679c                	ld	a5,8(a5)
    80004912:	cbe1                	beqz	a5,800049e2 <filewrite+0x148>
    ret = devsw[f->major].write(1, addr, n);
    80004914:	4505                	li	a0,1
    80004916:	9782                	jalr	a5
    80004918:	a049                	j	8000499a <filewrite+0x100>
    8000491a:	00098a1b          	sext.w	s4,s3
      int n1 = n - i;
      if(n1 > max)
        n1 = max;

      begin_op();
    8000491e:	00000097          	auipc	ra,0x0
    80004922:	87e080e7          	jalr	-1922(ra) # 8000419c <begin_op>
      ilock(f->ip);
    80004926:	6c88                	ld	a0,24(s1)
    80004928:	fffff097          	auipc	ra,0xfffff
    8000492c:	ea8080e7          	jalr	-344(ra) # 800037d0 <ilock>
      if ((r = writei(f->ip, 1, addr + i, f->off, n1)) > 0)
    80004930:	8752                	mv	a4,s4
    80004932:	5094                	lw	a3,32(s1)
    80004934:	01690633          	add	a2,s2,s6
    80004938:	4585                	li	a1,1
    8000493a:	6c88                	ld	a0,24(s1)
    8000493c:	fffff097          	auipc	ra,0xfffff
    80004940:	242080e7          	jalr	578(ra) # 80003b7e <writei>
    80004944:	89aa                	mv	s3,a0
    80004946:	02a05c63          	blez	a0,8000497e <filewrite+0xe4>
        f->off += r;
    8000494a:	509c                	lw	a5,32(s1)
    8000494c:	9fa9                	addw	a5,a5,a0
    8000494e:	d09c                	sw	a5,32(s1)
      iunlock(f->ip);
    80004950:	6c88                	ld	a0,24(s1)
    80004952:	fffff097          	auipc	ra,0xfffff
    80004956:	f42080e7          	jalr	-190(ra) # 80003894 <iunlock>
      end_op();
    8000495a:	00000097          	auipc	ra,0x0
    8000495e:	8c2080e7          	jalr	-1854(ra) # 8000421c <end_op>

      if(r < 0)
        break;
      if(r != n1)
    80004962:	05499863          	bne	s3,s4,800049b2 <filewrite+0x118>
        panic("short filewrite");
      i += r;
    80004966:	012a093b          	addw	s2,s4,s2
    while(i < n){
    8000496a:	03595563          	ble	s5,s2,80004994 <filewrite+0xfa>
      int n1 = n - i;
    8000496e:	412a87bb          	subw	a5,s5,s2
      if(n1 > max)
    80004972:	89be                	mv	s3,a5
    80004974:	2781                	sext.w	a5,a5
    80004976:	fafbd2e3          	ble	a5,s7,8000491a <filewrite+0x80>
    8000497a:	89e2                	mv	s3,s8
    8000497c:	bf79                	j	8000491a <filewrite+0x80>
      iunlock(f->ip);
    8000497e:	6c88                	ld	a0,24(s1)
    80004980:	fffff097          	auipc	ra,0xfffff
    80004984:	f14080e7          	jalr	-236(ra) # 80003894 <iunlock>
      end_op();
    80004988:	00000097          	auipc	ra,0x0
    8000498c:	894080e7          	jalr	-1900(ra) # 8000421c <end_op>
      if(r < 0)
    80004990:	fc09d9e3          	bgez	s3,80004962 <filewrite+0xc8>
    }
    ret = (i == n ? n : -1);
    80004994:	8556                	mv	a0,s5
    80004996:	032a9863          	bne	s5,s2,800049c6 <filewrite+0x12c>
  } else {
    panic("filewrite");
  }

  return ret;
}
    8000499a:	60a6                	ld	ra,72(sp)
    8000499c:	6406                	ld	s0,64(sp)
    8000499e:	74e2                	ld	s1,56(sp)
    800049a0:	7942                	ld	s2,48(sp)
    800049a2:	79a2                	ld	s3,40(sp)
    800049a4:	7a02                	ld	s4,32(sp)
    800049a6:	6ae2                	ld	s5,24(sp)
    800049a8:	6b42                	ld	s6,16(sp)
    800049aa:	6ba2                	ld	s7,8(sp)
    800049ac:	6c02                	ld	s8,0(sp)
    800049ae:	6161                	addi	sp,sp,80
    800049b0:	8082                	ret
        panic("short filewrite");
    800049b2:	00004517          	auipc	a0,0x4
    800049b6:	c7650513          	addi	a0,a0,-906 # 80008628 <syscalls+0x290>
    800049ba:	ffffc097          	auipc	ra,0xffffc
    800049be:	bba080e7          	jalr	-1094(ra) # 80000574 <panic>
    int i = 0;
    800049c2:	4901                	li	s2,0
    800049c4:	bfc1                	j	80004994 <filewrite+0xfa>
    ret = (i == n ? n : -1);
    800049c6:	557d                	li	a0,-1
    800049c8:	bfc9                	j	8000499a <filewrite+0x100>
    panic("filewrite");
    800049ca:	00004517          	auipc	a0,0x4
    800049ce:	c6e50513          	addi	a0,a0,-914 # 80008638 <syscalls+0x2a0>
    800049d2:	ffffc097          	auipc	ra,0xffffc
    800049d6:	ba2080e7          	jalr	-1118(ra) # 80000574 <panic>
    return -1;
    800049da:	557d                	li	a0,-1
}
    800049dc:	8082                	ret
      return -1;
    800049de:	557d                	li	a0,-1
    800049e0:	bf6d                	j	8000499a <filewrite+0x100>
    800049e2:	557d                	li	a0,-1
    800049e4:	bf5d                	j	8000499a <filewrite+0x100>

00000000800049e6 <pipealloc>:
  int writeopen;  // write fd is still open
};

int
pipealloc(struct file **f0, struct file **f1)
{
    800049e6:	7179                	addi	sp,sp,-48
    800049e8:	f406                	sd	ra,40(sp)
    800049ea:	f022                	sd	s0,32(sp)
    800049ec:	ec26                	sd	s1,24(sp)
    800049ee:	e84a                	sd	s2,16(sp)
    800049f0:	e44e                	sd	s3,8(sp)
    800049f2:	e052                	sd	s4,0(sp)
    800049f4:	1800                	addi	s0,sp,48
    800049f6:	84aa                	mv	s1,a0
    800049f8:	892e                	mv	s2,a1
  struct pipe *pi;

  pi = 0;
  *f0 = *f1 = 0;
    800049fa:	0005b023          	sd	zero,0(a1)
    800049fe:	00053023          	sd	zero,0(a0)
  if((*f0 = filealloc()) == 0 || (*f1 = filealloc()) == 0)
    80004a02:	00000097          	auipc	ra,0x0
    80004a06:	bcc080e7          	jalr	-1076(ra) # 800045ce <filealloc>
    80004a0a:	e088                	sd	a0,0(s1)
    80004a0c:	c551                	beqz	a0,80004a98 <pipealloc+0xb2>
    80004a0e:	00000097          	auipc	ra,0x0
    80004a12:	bc0080e7          	jalr	-1088(ra) # 800045ce <filealloc>
    80004a16:	00a93023          	sd	a0,0(s2)
    80004a1a:	c92d                	beqz	a0,80004a8c <pipealloc+0xa6>
    goto bad;
  if((pi = (struct pipe*)kalloc()) == 0)
    80004a1c:	ffffc097          	auipc	ra,0xffffc
    80004a20:	156080e7          	jalr	342(ra) # 80000b72 <kalloc>
    80004a24:	89aa                	mv	s3,a0
    80004a26:	c125                	beqz	a0,80004a86 <pipealloc+0xa0>
    goto bad;
  pi->readopen = 1;
    80004a28:	4a05                	li	s4,1
    80004a2a:	23452023          	sw	s4,544(a0)
  pi->writeopen = 1;
    80004a2e:	23452223          	sw	s4,548(a0)
  pi->nwrite = 0;
    80004a32:	20052e23          	sw	zero,540(a0)
  pi->nread = 0;
    80004a36:	20052c23          	sw	zero,536(a0)
  initlock(&pi->lock, "pipe");
    80004a3a:	00004597          	auipc	a1,0x4
    80004a3e:	c0e58593          	addi	a1,a1,-1010 # 80008648 <syscalls+0x2b0>
    80004a42:	ffffc097          	auipc	ra,0xffffc
    80004a46:	190080e7          	jalr	400(ra) # 80000bd2 <initlock>
  (*f0)->type = FD_PIPE;
    80004a4a:	609c                	ld	a5,0(s1)
    80004a4c:	0147a023          	sw	s4,0(a5)
  (*f0)->readable = 1;
    80004a50:	609c                	ld	a5,0(s1)
    80004a52:	01478423          	sb	s4,8(a5)
  (*f0)->writable = 0;
    80004a56:	609c                	ld	a5,0(s1)
    80004a58:	000784a3          	sb	zero,9(a5)
  (*f0)->pipe = pi;
    80004a5c:	609c                	ld	a5,0(s1)
    80004a5e:	0137b823          	sd	s3,16(a5)
  (*f1)->type = FD_PIPE;
    80004a62:	00093783          	ld	a5,0(s2)
    80004a66:	0147a023          	sw	s4,0(a5)
  (*f1)->readable = 0;
    80004a6a:	00093783          	ld	a5,0(s2)
    80004a6e:	00078423          	sb	zero,8(a5)
  (*f1)->writable = 1;
    80004a72:	00093783          	ld	a5,0(s2)
    80004a76:	014784a3          	sb	s4,9(a5)
  (*f1)->pipe = pi;
    80004a7a:	00093783          	ld	a5,0(s2)
    80004a7e:	0137b823          	sd	s3,16(a5)
  return 0;
    80004a82:	4501                	li	a0,0
    80004a84:	a025                	j	80004aac <pipealloc+0xc6>

 bad:
  if(pi)
    kfree((char*)pi);
  if(*f0)
    80004a86:	6088                	ld	a0,0(s1)
    80004a88:	e501                	bnez	a0,80004a90 <pipealloc+0xaa>
    80004a8a:	a039                	j	80004a98 <pipealloc+0xb2>
    80004a8c:	6088                	ld	a0,0(s1)
    80004a8e:	c51d                	beqz	a0,80004abc <pipealloc+0xd6>
    fileclose(*f0);
    80004a90:	00000097          	auipc	ra,0x0
    80004a94:	c0e080e7          	jalr	-1010(ra) # 8000469e <fileclose>
  if(*f1)
    80004a98:	00093783          	ld	a5,0(s2)
    fileclose(*f1);
  return -1;
    80004a9c:	557d                	li	a0,-1
  if(*f1)
    80004a9e:	c799                	beqz	a5,80004aac <pipealloc+0xc6>
    fileclose(*f1);
    80004aa0:	853e                	mv	a0,a5
    80004aa2:	00000097          	auipc	ra,0x0
    80004aa6:	bfc080e7          	jalr	-1028(ra) # 8000469e <fileclose>
  return -1;
    80004aaa:	557d                	li	a0,-1
}
    80004aac:	70a2                	ld	ra,40(sp)
    80004aae:	7402                	ld	s0,32(sp)
    80004ab0:	64e2                	ld	s1,24(sp)
    80004ab2:	6942                	ld	s2,16(sp)
    80004ab4:	69a2                	ld	s3,8(sp)
    80004ab6:	6a02                	ld	s4,0(sp)
    80004ab8:	6145                	addi	sp,sp,48
    80004aba:	8082                	ret
  return -1;
    80004abc:	557d                	li	a0,-1
    80004abe:	b7fd                	j	80004aac <pipealloc+0xc6>

0000000080004ac0 <pipeclose>:

void
pipeclose(struct pipe *pi, int writable)
{
    80004ac0:	1101                	addi	sp,sp,-32
    80004ac2:	ec06                	sd	ra,24(sp)
    80004ac4:	e822                	sd	s0,16(sp)
    80004ac6:	e426                	sd	s1,8(sp)
    80004ac8:	e04a                	sd	s2,0(sp)
    80004aca:	1000                	addi	s0,sp,32
    80004acc:	84aa                	mv	s1,a0
    80004ace:	892e                	mv	s2,a1
  acquire(&pi->lock);
    80004ad0:	ffffc097          	auipc	ra,0xffffc
    80004ad4:	192080e7          	jalr	402(ra) # 80000c62 <acquire>
  if(writable){
    80004ad8:	02090d63          	beqz	s2,80004b12 <pipeclose+0x52>
    pi->writeopen = 0;
    80004adc:	2204a223          	sw	zero,548(s1)
    wakeup(&pi->nread);
    80004ae0:	21848513          	addi	a0,s1,536
    80004ae4:	ffffe097          	auipc	ra,0xffffe
    80004ae8:	954080e7          	jalr	-1708(ra) # 80002438 <wakeup>
  } else {
    pi->readopen = 0;
    wakeup(&pi->nwrite);
  }
  if(pi->readopen == 0 && pi->writeopen == 0){
    80004aec:	2204b783          	ld	a5,544(s1)
    80004af0:	eb95                	bnez	a5,80004b24 <pipeclose+0x64>
    release(&pi->lock);
    80004af2:	8526                	mv	a0,s1
    80004af4:	ffffc097          	auipc	ra,0xffffc
    80004af8:	222080e7          	jalr	546(ra) # 80000d16 <release>
    kfree((char*)pi);
    80004afc:	8526                	mv	a0,s1
    80004afe:	ffffc097          	auipc	ra,0xffffc
    80004b02:	f74080e7          	jalr	-140(ra) # 80000a72 <kfree>
  } else
    release(&pi->lock);
}
    80004b06:	60e2                	ld	ra,24(sp)
    80004b08:	6442                	ld	s0,16(sp)
    80004b0a:	64a2                	ld	s1,8(sp)
    80004b0c:	6902                	ld	s2,0(sp)
    80004b0e:	6105                	addi	sp,sp,32
    80004b10:	8082                	ret
    pi->readopen = 0;
    80004b12:	2204a023          	sw	zero,544(s1)
    wakeup(&pi->nwrite);
    80004b16:	21c48513          	addi	a0,s1,540
    80004b1a:	ffffe097          	auipc	ra,0xffffe
    80004b1e:	91e080e7          	jalr	-1762(ra) # 80002438 <wakeup>
    80004b22:	b7e9                	j	80004aec <pipeclose+0x2c>
    release(&pi->lock);
    80004b24:	8526                	mv	a0,s1
    80004b26:	ffffc097          	auipc	ra,0xffffc
    80004b2a:	1f0080e7          	jalr	496(ra) # 80000d16 <release>
}
    80004b2e:	bfe1                	j	80004b06 <pipeclose+0x46>

0000000080004b30 <pipewrite>:

int
pipewrite(struct pipe *pi, uint64 addr, int n)
{
    80004b30:	7119                	addi	sp,sp,-128
    80004b32:	fc86                	sd	ra,120(sp)
    80004b34:	f8a2                	sd	s0,112(sp)
    80004b36:	f4a6                	sd	s1,104(sp)
    80004b38:	f0ca                	sd	s2,96(sp)
    80004b3a:	ecce                	sd	s3,88(sp)
    80004b3c:	e8d2                	sd	s4,80(sp)
    80004b3e:	e4d6                	sd	s5,72(sp)
    80004b40:	e0da                	sd	s6,64(sp)
    80004b42:	fc5e                	sd	s7,56(sp)
    80004b44:	f862                	sd	s8,48(sp)
    80004b46:	f466                	sd	s9,40(sp)
    80004b48:	f06a                	sd	s10,32(sp)
    80004b4a:	ec6e                	sd	s11,24(sp)
    80004b4c:	0100                	addi	s0,sp,128
    80004b4e:	84aa                	mv	s1,a0
    80004b50:	8d2e                	mv	s10,a1
    80004b52:	8b32                	mv	s6,a2
  int i;
  char ch;
  struct proc *pr = myproc();
    80004b54:	ffffd097          	auipc	ra,0xffffd
    80004b58:	f44080e7          	jalr	-188(ra) # 80001a98 <myproc>
    80004b5c:	892a                	mv	s2,a0

  acquire(&pi->lock);
    80004b5e:	8526                	mv	a0,s1
    80004b60:	ffffc097          	auipc	ra,0xffffc
    80004b64:	102080e7          	jalr	258(ra) # 80000c62 <acquire>
  for(i = 0; i < n; i++){
    80004b68:	0d605f63          	blez	s6,80004c46 <pipewrite+0x116>
    80004b6c:	89a6                	mv	s3,s1
    80004b6e:	3b7d                	addiw	s6,s6,-1
    80004b70:	1b02                	slli	s6,s6,0x20
    80004b72:	020b5b13          	srli	s6,s6,0x20
    80004b76:	4b81                	li	s7,0
    while(pi->nwrite == pi->nread + PIPESIZE){  //DOC: pipewrite-full
      if(pi->readopen == 0 || pr->killed){
        release(&pi->lock);
        return -1;
      }
      wakeup(&pi->nread);
    80004b78:	21848a93          	addi	s5,s1,536
      sleep(&pi->nwrite, &pi->lock);
    80004b7c:	21c48a13          	addi	s4,s1,540
    }
    if(copyin(pr->pagetable, &ch, addr + i, 1) == -1)
    80004b80:	5dfd                	li	s11,-1
    80004b82:	000b8c9b          	sext.w	s9,s7
    80004b86:	8c66                	mv	s8,s9
    while(pi->nwrite == pi->nread + PIPESIZE){  //DOC: pipewrite-full
    80004b88:	2184a783          	lw	a5,536(s1)
    80004b8c:	21c4a703          	lw	a4,540(s1)
    80004b90:	2007879b          	addiw	a5,a5,512
    80004b94:	06f71763          	bne	a4,a5,80004c02 <pipewrite+0xd2>
      if(pi->readopen == 0 || pr->killed){
    80004b98:	2204a783          	lw	a5,544(s1)
    80004b9c:	cf8d                	beqz	a5,80004bd6 <pipewrite+0xa6>
    80004b9e:	03092783          	lw	a5,48(s2)
    80004ba2:	eb95                	bnez	a5,80004bd6 <pipewrite+0xa6>
      wakeup(&pi->nread);
    80004ba4:	8556                	mv	a0,s5
    80004ba6:	ffffe097          	auipc	ra,0xffffe
    80004baa:	892080e7          	jalr	-1902(ra) # 80002438 <wakeup>
      sleep(&pi->nwrite, &pi->lock);
    80004bae:	85ce                	mv	a1,s3
    80004bb0:	8552                	mv	a0,s4
    80004bb2:	ffffd097          	auipc	ra,0xffffd
    80004bb6:	700080e7          	jalr	1792(ra) # 800022b2 <sleep>
    while(pi->nwrite == pi->nread + PIPESIZE){  //DOC: pipewrite-full
    80004bba:	2184a783          	lw	a5,536(s1)
    80004bbe:	21c4a703          	lw	a4,540(s1)
    80004bc2:	2007879b          	addiw	a5,a5,512
    80004bc6:	02f71e63          	bne	a4,a5,80004c02 <pipewrite+0xd2>
      if(pi->readopen == 0 || pr->killed){
    80004bca:	2204a783          	lw	a5,544(s1)
    80004bce:	c781                	beqz	a5,80004bd6 <pipewrite+0xa6>
    80004bd0:	03092783          	lw	a5,48(s2)
    80004bd4:	dbe1                	beqz	a5,80004ba4 <pipewrite+0x74>
        release(&pi->lock);
    80004bd6:	8526                	mv	a0,s1
    80004bd8:	ffffc097          	auipc	ra,0xffffc
    80004bdc:	13e080e7          	jalr	318(ra) # 80000d16 <release>
        return -1;
    80004be0:	5c7d                	li	s8,-1
    pi->data[pi->nwrite++ % PIPESIZE] = ch;
  }
  wakeup(&pi->nread);
  release(&pi->lock);
  return i;
}
    80004be2:	8562                	mv	a0,s8
    80004be4:	70e6                	ld	ra,120(sp)
    80004be6:	7446                	ld	s0,112(sp)
    80004be8:	74a6                	ld	s1,104(sp)
    80004bea:	7906                	ld	s2,96(sp)
    80004bec:	69e6                	ld	s3,88(sp)
    80004bee:	6a46                	ld	s4,80(sp)
    80004bf0:	6aa6                	ld	s5,72(sp)
    80004bf2:	6b06                	ld	s6,64(sp)
    80004bf4:	7be2                	ld	s7,56(sp)
    80004bf6:	7c42                	ld	s8,48(sp)
    80004bf8:	7ca2                	ld	s9,40(sp)
    80004bfa:	7d02                	ld	s10,32(sp)
    80004bfc:	6de2                	ld	s11,24(sp)
    80004bfe:	6109                	addi	sp,sp,128
    80004c00:	8082                	ret
    if(copyin(pr->pagetable, &ch, addr + i, 1) == -1)
    80004c02:	4685                	li	a3,1
    80004c04:	01ab8633          	add	a2,s7,s10
    80004c08:	f8f40593          	addi	a1,s0,-113
    80004c0c:	05093503          	ld	a0,80(s2)
    80004c10:	ffffd097          	auipc	ra,0xffffd
    80004c14:	bf0080e7          	jalr	-1040(ra) # 80001800 <copyin>
    80004c18:	03b50863          	beq	a0,s11,80004c48 <pipewrite+0x118>
    pi->data[pi->nwrite++ % PIPESIZE] = ch;
    80004c1c:	21c4a783          	lw	a5,540(s1)
    80004c20:	0017871b          	addiw	a4,a5,1
    80004c24:	20e4ae23          	sw	a4,540(s1)
    80004c28:	1ff7f793          	andi	a5,a5,511
    80004c2c:	97a6                	add	a5,a5,s1
    80004c2e:	f8f44703          	lbu	a4,-113(s0)
    80004c32:	00e78c23          	sb	a4,24(a5)
  for(i = 0; i < n; i++){
    80004c36:	001c8c1b          	addiw	s8,s9,1
    80004c3a:	001b8793          	addi	a5,s7,1
    80004c3e:	016b8563          	beq	s7,s6,80004c48 <pipewrite+0x118>
    80004c42:	8bbe                	mv	s7,a5
    80004c44:	bf3d                	j	80004b82 <pipewrite+0x52>
    80004c46:	4c01                	li	s8,0
  wakeup(&pi->nread);
    80004c48:	21848513          	addi	a0,s1,536
    80004c4c:	ffffd097          	auipc	ra,0xffffd
    80004c50:	7ec080e7          	jalr	2028(ra) # 80002438 <wakeup>
  release(&pi->lock);
    80004c54:	8526                	mv	a0,s1
    80004c56:	ffffc097          	auipc	ra,0xffffc
    80004c5a:	0c0080e7          	jalr	192(ra) # 80000d16 <release>
  return i;
    80004c5e:	b751                	j	80004be2 <pipewrite+0xb2>

0000000080004c60 <piperead>:

int
piperead(struct pipe *pi, uint64 addr, int n)
{
    80004c60:	715d                	addi	sp,sp,-80
    80004c62:	e486                	sd	ra,72(sp)
    80004c64:	e0a2                	sd	s0,64(sp)
    80004c66:	fc26                	sd	s1,56(sp)
    80004c68:	f84a                	sd	s2,48(sp)
    80004c6a:	f44e                	sd	s3,40(sp)
    80004c6c:	f052                	sd	s4,32(sp)
    80004c6e:	ec56                	sd	s5,24(sp)
    80004c70:	e85a                	sd	s6,16(sp)
    80004c72:	0880                	addi	s0,sp,80
    80004c74:	84aa                	mv	s1,a0
    80004c76:	89ae                	mv	s3,a1
    80004c78:	8ab2                	mv	s5,a2
  int i;
  struct proc *pr = myproc();
    80004c7a:	ffffd097          	auipc	ra,0xffffd
    80004c7e:	e1e080e7          	jalr	-482(ra) # 80001a98 <myproc>
    80004c82:	8a2a                	mv	s4,a0
  char ch;

  acquire(&pi->lock);
    80004c84:	8526                	mv	a0,s1
    80004c86:	ffffc097          	auipc	ra,0xffffc
    80004c8a:	fdc080e7          	jalr	-36(ra) # 80000c62 <acquire>
  while(pi->nread == pi->nwrite && pi->writeopen){  //DOC: pipe-empty
    80004c8e:	2184a703          	lw	a4,536(s1)
    80004c92:	21c4a783          	lw	a5,540(s1)
    80004c96:	06f71b63          	bne	a4,a5,80004d0c <piperead+0xac>
    80004c9a:	8926                	mv	s2,s1
    80004c9c:	2244a783          	lw	a5,548(s1)
    80004ca0:	cf9d                	beqz	a5,80004cde <piperead+0x7e>
    if(pr->killed){
    80004ca2:	030a2783          	lw	a5,48(s4)
    80004ca6:	e78d                	bnez	a5,80004cd0 <piperead+0x70>
      release(&pi->lock);
      return -1;
    }
    sleep(&pi->nread, &pi->lock); //DOC: piperead-sleep
    80004ca8:	21848b13          	addi	s6,s1,536
    80004cac:	85ca                	mv	a1,s2
    80004cae:	855a                	mv	a0,s6
    80004cb0:	ffffd097          	auipc	ra,0xffffd
    80004cb4:	602080e7          	jalr	1538(ra) # 800022b2 <sleep>
  while(pi->nread == pi->nwrite && pi->writeopen){  //DOC: pipe-empty
    80004cb8:	2184a703          	lw	a4,536(s1)
    80004cbc:	21c4a783          	lw	a5,540(s1)
    80004cc0:	04f71663          	bne	a4,a5,80004d0c <piperead+0xac>
    80004cc4:	2244a783          	lw	a5,548(s1)
    80004cc8:	cb99                	beqz	a5,80004cde <piperead+0x7e>
    if(pr->killed){
    80004cca:	030a2783          	lw	a5,48(s4)
    80004cce:	dff9                	beqz	a5,80004cac <piperead+0x4c>
      release(&pi->lock);
    80004cd0:	8526                	mv	a0,s1
    80004cd2:	ffffc097          	auipc	ra,0xffffc
    80004cd6:	044080e7          	jalr	68(ra) # 80000d16 <release>
      return -1;
    80004cda:	597d                	li	s2,-1
    80004cdc:	a829                	j	80004cf6 <piperead+0x96>
  }
  for(i = 0; i < n; i++){  //DOC: piperead-copy
    if(pi->nread == pi->nwrite)
    80004cde:	4901                	li	s2,0
      break;
    ch = pi->data[pi->nread++ % PIPESIZE];
    if(copyout(pr->pagetable, addr + i, &ch, 1) == -1)
      break;
  }
  wakeup(&pi->nwrite);  //DOC: piperead-wakeup
    80004ce0:	21c48513          	addi	a0,s1,540
    80004ce4:	ffffd097          	auipc	ra,0xffffd
    80004ce8:	754080e7          	jalr	1876(ra) # 80002438 <wakeup>
  release(&pi->lock);
    80004cec:	8526                	mv	a0,s1
    80004cee:	ffffc097          	auipc	ra,0xffffc
    80004cf2:	028080e7          	jalr	40(ra) # 80000d16 <release>
  return i;
}
    80004cf6:	854a                	mv	a0,s2
    80004cf8:	60a6                	ld	ra,72(sp)
    80004cfa:	6406                	ld	s0,64(sp)
    80004cfc:	74e2                	ld	s1,56(sp)
    80004cfe:	7942                	ld	s2,48(sp)
    80004d00:	79a2                	ld	s3,40(sp)
    80004d02:	7a02                	ld	s4,32(sp)
    80004d04:	6ae2                	ld	s5,24(sp)
    80004d06:	6b42                	ld	s6,16(sp)
    80004d08:	6161                	addi	sp,sp,80
    80004d0a:	8082                	ret
  for(i = 0; i < n; i++){  //DOC: piperead-copy
    80004d0c:	4901                	li	s2,0
    80004d0e:	fd5059e3          	blez	s5,80004ce0 <piperead+0x80>
    if(pi->nread == pi->nwrite)
    80004d12:	2184a783          	lw	a5,536(s1)
    80004d16:	4901                	li	s2,0
    if(copyout(pr->pagetable, addr + i, &ch, 1) == -1)
    80004d18:	5b7d                	li	s6,-1
    ch = pi->data[pi->nread++ % PIPESIZE];
    80004d1a:	0017871b          	addiw	a4,a5,1
    80004d1e:	20e4ac23          	sw	a4,536(s1)
    80004d22:	1ff7f793          	andi	a5,a5,511
    80004d26:	97a6                	add	a5,a5,s1
    80004d28:	0187c783          	lbu	a5,24(a5)
    80004d2c:	faf40fa3          	sb	a5,-65(s0)
    if(copyout(pr->pagetable, addr + i, &ch, 1) == -1)
    80004d30:	4685                	li	a3,1
    80004d32:	fbf40613          	addi	a2,s0,-65
    80004d36:	85ce                	mv	a1,s3
    80004d38:	050a3503          	ld	a0,80(s4)
    80004d3c:	ffffd097          	auipc	ra,0xffffd
    80004d40:	a38080e7          	jalr	-1480(ra) # 80001774 <copyout>
    80004d44:	f9650ee3          	beq	a0,s6,80004ce0 <piperead+0x80>
  for(i = 0; i < n; i++){  //DOC: piperead-copy
    80004d48:	2905                	addiw	s2,s2,1
    80004d4a:	f92a8be3          	beq	s5,s2,80004ce0 <piperead+0x80>
    if(pi->nread == pi->nwrite)
    80004d4e:	2184a783          	lw	a5,536(s1)
    80004d52:	0985                	addi	s3,s3,1
    80004d54:	21c4a703          	lw	a4,540(s1)
    80004d58:	fcf711e3          	bne	a4,a5,80004d1a <piperead+0xba>
    80004d5c:	b751                	j	80004ce0 <piperead+0x80>

0000000080004d5e <exec>:

static int loadseg(pde_t *pgdir, uint64 addr, struct inode *ip, uint offset, uint sz);

int
exec(char *path, char **argv)
{
    80004d5e:	de010113          	addi	sp,sp,-544
    80004d62:	20113c23          	sd	ra,536(sp)
    80004d66:	20813823          	sd	s0,528(sp)
    80004d6a:	20913423          	sd	s1,520(sp)
    80004d6e:	21213023          	sd	s2,512(sp)
    80004d72:	ffce                	sd	s3,504(sp)
    80004d74:	fbd2                	sd	s4,496(sp)
    80004d76:	f7d6                	sd	s5,488(sp)
    80004d78:	f3da                	sd	s6,480(sp)
    80004d7a:	efde                	sd	s7,472(sp)
    80004d7c:	ebe2                	sd	s8,464(sp)
    80004d7e:	e7e6                	sd	s9,456(sp)
    80004d80:	e3ea                	sd	s10,448(sp)
    80004d82:	ff6e                	sd	s11,440(sp)
    80004d84:	1400                	addi	s0,sp,544
    80004d86:	892a                	mv	s2,a0
    80004d88:	dea43823          	sd	a0,-528(s0)
    80004d8c:	deb43c23          	sd	a1,-520(s0)
  uint64 argc, sz = 0, sp, ustack[MAXARG+1], stackbase;
  struct elfhdr elf;
  struct inode *ip;
  struct proghdr ph;
  pagetable_t pagetable = 0, oldpagetable;
  struct proc *p = myproc();
    80004d90:	ffffd097          	auipc	ra,0xffffd
    80004d94:	d08080e7          	jalr	-760(ra) # 80001a98 <myproc>
    80004d98:	84aa                	mv	s1,a0

  begin_op();
    80004d9a:	fffff097          	auipc	ra,0xfffff
    80004d9e:	402080e7          	jalr	1026(ra) # 8000419c <begin_op>

  if((ip = namei(path)) == 0){
    80004da2:	854a                	mv	a0,s2
    80004da4:	fffff097          	auipc	ra,0xfffff
    80004da8:	1ea080e7          	jalr	490(ra) # 80003f8e <namei>
    80004dac:	c93d                	beqz	a0,80004e22 <exec+0xc4>
    80004dae:	892a                	mv	s2,a0
    end_op();
    return -1;
  }
  ilock(ip);
    80004db0:	fffff097          	auipc	ra,0xfffff
    80004db4:	a20080e7          	jalr	-1504(ra) # 800037d0 <ilock>

  // Check ELF header
  if(readi(ip, 0, (uint64)&elf, 0, sizeof(elf)) != sizeof(elf))
    80004db8:	04000713          	li	a4,64
    80004dbc:	4681                	li	a3,0
    80004dbe:	e4840613          	addi	a2,s0,-440
    80004dc2:	4581                	li	a1,0
    80004dc4:	854a                	mv	a0,s2
    80004dc6:	fffff097          	auipc	ra,0xfffff
    80004dca:	cc0080e7          	jalr	-832(ra) # 80003a86 <readi>
    80004dce:	04000793          	li	a5,64
    80004dd2:	00f51a63          	bne	a0,a5,80004de6 <exec+0x88>
    goto bad;
  if(elf.magic != ELF_MAGIC)
    80004dd6:	e4842703          	lw	a4,-440(s0)
    80004dda:	464c47b7          	lui	a5,0x464c4
    80004dde:	57f78793          	addi	a5,a5,1407 # 464c457f <_entry-0x39b3ba81>
    80004de2:	04f70663          	beq	a4,a5,80004e2e <exec+0xd0>

 bad:
  if(pagetable)
    proc_freepagetable(pagetable, sz);
  if(ip){
    iunlockput(ip);
    80004de6:	854a                	mv	a0,s2
    80004de8:	fffff097          	auipc	ra,0xfffff
    80004dec:	c4c080e7          	jalr	-948(ra) # 80003a34 <iunlockput>
    end_op();
    80004df0:	fffff097          	auipc	ra,0xfffff
    80004df4:	42c080e7          	jalr	1068(ra) # 8000421c <end_op>
  }
  return -1;
    80004df8:	557d                	li	a0,-1
}
    80004dfa:	21813083          	ld	ra,536(sp)
    80004dfe:	21013403          	ld	s0,528(sp)
    80004e02:	20813483          	ld	s1,520(sp)
    80004e06:	20013903          	ld	s2,512(sp)
    80004e0a:	79fe                	ld	s3,504(sp)
    80004e0c:	7a5e                	ld	s4,496(sp)
    80004e0e:	7abe                	ld	s5,488(sp)
    80004e10:	7b1e                	ld	s6,480(sp)
    80004e12:	6bfe                	ld	s7,472(sp)
    80004e14:	6c5e                	ld	s8,464(sp)
    80004e16:	6cbe                	ld	s9,456(sp)
    80004e18:	6d1e                	ld	s10,448(sp)
    80004e1a:	7dfa                	ld	s11,440(sp)
    80004e1c:	22010113          	addi	sp,sp,544
    80004e20:	8082                	ret
    end_op();
    80004e22:	fffff097          	auipc	ra,0xfffff
    80004e26:	3fa080e7          	jalr	1018(ra) # 8000421c <end_op>
    return -1;
    80004e2a:	557d                	li	a0,-1
    80004e2c:	b7f9                	j	80004dfa <exec+0x9c>
  if((pagetable = proc_pagetable(p)) == 0)
    80004e2e:	8526                	mv	a0,s1
    80004e30:	ffffd097          	auipc	ra,0xffffd
    80004e34:	d2e080e7          	jalr	-722(ra) # 80001b5e <proc_pagetable>
    80004e38:	e0a43423          	sd	a0,-504(s0)
    80004e3c:	d54d                	beqz	a0,80004de6 <exec+0x88>
  for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
    80004e3e:	e6842983          	lw	s3,-408(s0)
    80004e42:	e8045783          	lhu	a5,-384(s0)
    80004e46:	c7ad                	beqz	a5,80004eb0 <exec+0x152>
  uint64 argc, sz = 0, sp, ustack[MAXARG+1], stackbase;
    80004e48:	4481                	li	s1,0
  for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
    80004e4a:	4b01                	li	s6,0
    if(ph.vaddr % PGSIZE != 0)
    80004e4c:	6c05                	lui	s8,0x1
    80004e4e:	fffc0793          	addi	a5,s8,-1 # fff <_entry-0x7ffff001>
    80004e52:	def43423          	sd	a5,-536(s0)
    80004e56:	7cfd                	lui	s9,0xfffff
    80004e58:	ac1d                	j	8000508e <exec+0x330>
    panic("loadseg: va must be page aligned");

  for(i = 0; i < sz; i += PGSIZE){
    pa = walkaddr(pagetable, va + i);
    if(pa == 0)
      panic("loadseg: address should exist");
    80004e5a:	00003517          	auipc	a0,0x3
    80004e5e:	7f650513          	addi	a0,a0,2038 # 80008650 <syscalls+0x2b8>
    80004e62:	ffffb097          	auipc	ra,0xffffb
    80004e66:	712080e7          	jalr	1810(ra) # 80000574 <panic>
    if(sz - i < PGSIZE)
      n = sz - i;
    else
      n = PGSIZE;
    if(readi(ip, 0, (uint64)pa, offset+i, n) != n)
    80004e6a:	8756                	mv	a4,s5
    80004e6c:	009d86bb          	addw	a3,s11,s1
    80004e70:	4581                	li	a1,0
    80004e72:	854a                	mv	a0,s2
    80004e74:	fffff097          	auipc	ra,0xfffff
    80004e78:	c12080e7          	jalr	-1006(ra) # 80003a86 <readi>
    80004e7c:	2501                	sext.w	a0,a0
    80004e7e:	1aaa9e63          	bne	s5,a0,8000503a <exec+0x2dc>
  for(i = 0; i < sz; i += PGSIZE){
    80004e82:	6785                	lui	a5,0x1
    80004e84:	9cbd                	addw	s1,s1,a5
    80004e86:	014c8a3b          	addw	s4,s9,s4
    80004e8a:	1f74f963          	bleu	s7,s1,8000507c <exec+0x31e>
    pa = walkaddr(pagetable, va + i);
    80004e8e:	02049593          	slli	a1,s1,0x20
    80004e92:	9181                	srli	a1,a1,0x20
    80004e94:	95ea                	add	a1,a1,s10
    80004e96:	e0843503          	ld	a0,-504(s0)
    80004e9a:	ffffc097          	auipc	ra,0xffffc
    80004e9e:	368080e7          	jalr	872(ra) # 80001202 <walkaddr>
    80004ea2:	862a                	mv	a2,a0
    if(pa == 0)
    80004ea4:	d95d                	beqz	a0,80004e5a <exec+0xfc>
      n = PGSIZE;
    80004ea6:	8ae2                	mv	s5,s8
    if(sz - i < PGSIZE)
    80004ea8:	fd8a71e3          	bleu	s8,s4,80004e6a <exec+0x10c>
      n = sz - i;
    80004eac:	8ad2                	mv	s5,s4
    80004eae:	bf75                	j	80004e6a <exec+0x10c>
  uint64 argc, sz = 0, sp, ustack[MAXARG+1], stackbase;
    80004eb0:	4481                	li	s1,0
  iunlockput(ip);
    80004eb2:	854a                	mv	a0,s2
    80004eb4:	fffff097          	auipc	ra,0xfffff
    80004eb8:	b80080e7          	jalr	-1152(ra) # 80003a34 <iunlockput>
  end_op();
    80004ebc:	fffff097          	auipc	ra,0xfffff
    80004ec0:	360080e7          	jalr	864(ra) # 8000421c <end_op>
  p = myproc();
    80004ec4:	ffffd097          	auipc	ra,0xffffd
    80004ec8:	bd4080e7          	jalr	-1068(ra) # 80001a98 <myproc>
    80004ecc:	8aaa                	mv	s5,a0
  uint64 oldsz = p->sz;
    80004ece:	04853d03          	ld	s10,72(a0)
  sz = PGROUNDUP(sz);
    80004ed2:	6785                	lui	a5,0x1
    80004ed4:	17fd                	addi	a5,a5,-1
    80004ed6:	94be                	add	s1,s1,a5
    80004ed8:	77fd                	lui	a5,0xfffff
    80004eda:	8fe5                	and	a5,a5,s1
    80004edc:	e0f43023          	sd	a5,-512(s0)
  if((sz1 = uvmalloc(pagetable, sz, sz + 2*PGSIZE)) == 0)
    80004ee0:	6609                	lui	a2,0x2
    80004ee2:	963e                	add	a2,a2,a5
    80004ee4:	85be                	mv	a1,a5
    80004ee6:	e0843483          	ld	s1,-504(s0)
    80004eea:	8526                	mv	a0,s1
    80004eec:	ffffc097          	auipc	ra,0xffffc
    80004ef0:	654080e7          	jalr	1620(ra) # 80001540 <uvmalloc>
    80004ef4:	8b2a                	mv	s6,a0
  ip = 0;
    80004ef6:	4901                	li	s2,0
  if((sz1 = uvmalloc(pagetable, sz, sz + 2*PGSIZE)) == 0)
    80004ef8:	14050163          	beqz	a0,8000503a <exec+0x2dc>
  uvmclear(pagetable, sz-2*PGSIZE);
    80004efc:	75f9                	lui	a1,0xffffe
    80004efe:	95aa                	add	a1,a1,a0
    80004f00:	8526                	mv	a0,s1
    80004f02:	ffffd097          	auipc	ra,0xffffd
    80004f06:	840080e7          	jalr	-1984(ra) # 80001742 <uvmclear>
  stackbase = sp - PGSIZE;
    80004f0a:	7bfd                	lui	s7,0xfffff
    80004f0c:	9bda                	add	s7,s7,s6
  for(argc = 0; argv[argc]; argc++) {
    80004f0e:	df843783          	ld	a5,-520(s0)
    80004f12:	6388                	ld	a0,0(a5)
    80004f14:	c925                	beqz	a0,80004f84 <exec+0x226>
    80004f16:	e8840993          	addi	s3,s0,-376
    80004f1a:	f8840c13          	addi	s8,s0,-120
  sp = sz;
    80004f1e:	895a                	mv	s2,s6
  for(argc = 0; argv[argc]; argc++) {
    80004f20:	4481                	li	s1,0
    sp -= strlen(argv[argc]) + 1;
    80004f22:	ffffc097          	auipc	ra,0xffffc
    80004f26:	fe6080e7          	jalr	-26(ra) # 80000f08 <strlen>
    80004f2a:	2505                	addiw	a0,a0,1
    80004f2c:	40a90933          	sub	s2,s2,a0
    sp -= sp % 16; // riscv sp must be 16-byte aligned
    80004f30:	ff097913          	andi	s2,s2,-16
    if(sp < stackbase)
    80004f34:	13796863          	bltu	s2,s7,80005064 <exec+0x306>
    if(copyout(pagetable, sp, argv[argc], strlen(argv[argc]) + 1) < 0)
    80004f38:	df843c83          	ld	s9,-520(s0)
    80004f3c:	000cba03          	ld	s4,0(s9) # fffffffffffff000 <end+0xffffffff7ffd9000>
    80004f40:	8552                	mv	a0,s4
    80004f42:	ffffc097          	auipc	ra,0xffffc
    80004f46:	fc6080e7          	jalr	-58(ra) # 80000f08 <strlen>
    80004f4a:	0015069b          	addiw	a3,a0,1
    80004f4e:	8652                	mv	a2,s4
    80004f50:	85ca                	mv	a1,s2
    80004f52:	e0843503          	ld	a0,-504(s0)
    80004f56:	ffffd097          	auipc	ra,0xffffd
    80004f5a:	81e080e7          	jalr	-2018(ra) # 80001774 <copyout>
    80004f5e:	10054763          	bltz	a0,8000506c <exec+0x30e>
    ustack[argc] = sp;
    80004f62:	0129b023          	sd	s2,0(s3)
  for(argc = 0; argv[argc]; argc++) {
    80004f66:	0485                	addi	s1,s1,1
    80004f68:	008c8793          	addi	a5,s9,8
    80004f6c:	def43c23          	sd	a5,-520(s0)
    80004f70:	008cb503          	ld	a0,8(s9)
    80004f74:	c911                	beqz	a0,80004f88 <exec+0x22a>
    if(argc >= MAXARG)
    80004f76:	09a1                	addi	s3,s3,8
    80004f78:	fb8995e3          	bne	s3,s8,80004f22 <exec+0x1c4>
  sz = sz1;
    80004f7c:	e1643023          	sd	s6,-512(s0)
  ip = 0;
    80004f80:	4901                	li	s2,0
    80004f82:	a865                	j	8000503a <exec+0x2dc>
  sp = sz;
    80004f84:	895a                	mv	s2,s6
  for(argc = 0; argv[argc]; argc++) {
    80004f86:	4481                	li	s1,0
  ustack[argc] = 0;
    80004f88:	00349793          	slli	a5,s1,0x3
    80004f8c:	f9040713          	addi	a4,s0,-112
    80004f90:	97ba                	add	a5,a5,a4
    80004f92:	ee07bc23          	sd	zero,-264(a5) # ffffffffffffeef8 <end+0xffffffff7ffd8ef8>
  sp -= (argc+1) * sizeof(uint64);
    80004f96:	00148693          	addi	a3,s1,1
    80004f9a:	068e                	slli	a3,a3,0x3
    80004f9c:	40d90933          	sub	s2,s2,a3
  sp -= sp % 16;
    80004fa0:	ff097913          	andi	s2,s2,-16
  if(sp < stackbase)
    80004fa4:	01797663          	bleu	s7,s2,80004fb0 <exec+0x252>
  sz = sz1;
    80004fa8:	e1643023          	sd	s6,-512(s0)
  ip = 0;
    80004fac:	4901                	li	s2,0
    80004fae:	a071                	j	8000503a <exec+0x2dc>
  if(copyout(pagetable, sp, (char *)ustack, (argc+1)*sizeof(uint64)) < 0)
    80004fb0:	e8840613          	addi	a2,s0,-376
    80004fb4:	85ca                	mv	a1,s2
    80004fb6:	e0843503          	ld	a0,-504(s0)
    80004fba:	ffffc097          	auipc	ra,0xffffc
    80004fbe:	7ba080e7          	jalr	1978(ra) # 80001774 <copyout>
    80004fc2:	0a054963          	bltz	a0,80005074 <exec+0x316>
  p->trapframe->a1 = sp;
    80004fc6:	058ab783          	ld	a5,88(s5)
    80004fca:	0727bc23          	sd	s2,120(a5)
  for(last=s=path; *s; s++)
    80004fce:	df043783          	ld	a5,-528(s0)
    80004fd2:	0007c703          	lbu	a4,0(a5)
    80004fd6:	cf11                	beqz	a4,80004ff2 <exec+0x294>
    80004fd8:	0785                	addi	a5,a5,1
    if(*s == '/')
    80004fda:	02f00693          	li	a3,47
    80004fde:	a029                	j	80004fe8 <exec+0x28a>
  for(last=s=path; *s; s++)
    80004fe0:	0785                	addi	a5,a5,1
    80004fe2:	fff7c703          	lbu	a4,-1(a5)
    80004fe6:	c711                	beqz	a4,80004ff2 <exec+0x294>
    if(*s == '/')
    80004fe8:	fed71ce3          	bne	a4,a3,80004fe0 <exec+0x282>
      last = s+1;
    80004fec:	def43823          	sd	a5,-528(s0)
    80004ff0:	bfc5                	j	80004fe0 <exec+0x282>
  safestrcpy(p->name, last, sizeof(p->name));
    80004ff2:	4641                	li	a2,16
    80004ff4:	df043583          	ld	a1,-528(s0)
    80004ff8:	158a8513          	addi	a0,s5,344
    80004ffc:	ffffc097          	auipc	ra,0xffffc
    80005000:	eda080e7          	jalr	-294(ra) # 80000ed6 <safestrcpy>
  oldpagetable = p->pagetable;
    80005004:	050ab503          	ld	a0,80(s5)
  p->pagetable = pagetable;
    80005008:	e0843783          	ld	a5,-504(s0)
    8000500c:	04fab823          	sd	a5,80(s5)
  p->sz = sz;
    80005010:	056ab423          	sd	s6,72(s5)
  p->trapframe->epc = elf.entry;  // initial program counter = main
    80005014:	058ab783          	ld	a5,88(s5)
    80005018:	e6043703          	ld	a4,-416(s0)
    8000501c:	ef98                	sd	a4,24(a5)
  p->trapframe->sp = sp; // initial stack pointer
    8000501e:	058ab783          	ld	a5,88(s5)
    80005022:	0327b823          	sd	s2,48(a5)
  proc_freepagetable(oldpagetable, oldsz);
    80005026:	85ea                	mv	a1,s10
    80005028:	ffffd097          	auipc	ra,0xffffd
    8000502c:	bd2080e7          	jalr	-1070(ra) # 80001bfa <proc_freepagetable>
  return argc; // this ends up in a0, the first argument to main(argc, argv)
    80005030:	0004851b          	sext.w	a0,s1
    80005034:	b3d9                	j	80004dfa <exec+0x9c>
    80005036:	e0943023          	sd	s1,-512(s0)
    proc_freepagetable(pagetable, sz);
    8000503a:	e0043583          	ld	a1,-512(s0)
    8000503e:	e0843503          	ld	a0,-504(s0)
    80005042:	ffffd097          	auipc	ra,0xffffd
    80005046:	bb8080e7          	jalr	-1096(ra) # 80001bfa <proc_freepagetable>
  if(ip){
    8000504a:	d8091ee3          	bnez	s2,80004de6 <exec+0x88>
  return -1;
    8000504e:	557d                	li	a0,-1
    80005050:	b36d                	j	80004dfa <exec+0x9c>
    80005052:	e0943023          	sd	s1,-512(s0)
    80005056:	b7d5                	j	8000503a <exec+0x2dc>
    80005058:	e0943023          	sd	s1,-512(s0)
    8000505c:	bff9                	j	8000503a <exec+0x2dc>
    8000505e:	e0943023          	sd	s1,-512(s0)
    80005062:	bfe1                	j	8000503a <exec+0x2dc>
  sz = sz1;
    80005064:	e1643023          	sd	s6,-512(s0)
  ip = 0;
    80005068:	4901                	li	s2,0
    8000506a:	bfc1                	j	8000503a <exec+0x2dc>
  sz = sz1;
    8000506c:	e1643023          	sd	s6,-512(s0)
  ip = 0;
    80005070:	4901                	li	s2,0
    80005072:	b7e1                	j	8000503a <exec+0x2dc>
  sz = sz1;
    80005074:	e1643023          	sd	s6,-512(s0)
  ip = 0;
    80005078:	4901                	li	s2,0
    8000507a:	b7c1                	j	8000503a <exec+0x2dc>
    if((sz1 = uvmalloc(pagetable, sz, ph.vaddr + ph.memsz)) == 0)
    8000507c:	e0043483          	ld	s1,-512(s0)
  for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
    80005080:	2b05                	addiw	s6,s6,1
    80005082:	0389899b          	addiw	s3,s3,56
    80005086:	e8045783          	lhu	a5,-384(s0)
    8000508a:	e2fb54e3          	ble	a5,s6,80004eb2 <exec+0x154>
    if(readi(ip, 0, (uint64)&ph, off, sizeof(ph)) != sizeof(ph))
    8000508e:	2981                	sext.w	s3,s3
    80005090:	03800713          	li	a4,56
    80005094:	86ce                	mv	a3,s3
    80005096:	e1040613          	addi	a2,s0,-496
    8000509a:	4581                	li	a1,0
    8000509c:	854a                	mv	a0,s2
    8000509e:	fffff097          	auipc	ra,0xfffff
    800050a2:	9e8080e7          	jalr	-1560(ra) # 80003a86 <readi>
    800050a6:	03800793          	li	a5,56
    800050aa:	f8f516e3          	bne	a0,a5,80005036 <exec+0x2d8>
    if(ph.type != ELF_PROG_LOAD)
    800050ae:	e1042783          	lw	a5,-496(s0)
    800050b2:	4705                	li	a4,1
    800050b4:	fce796e3          	bne	a5,a4,80005080 <exec+0x322>
    if(ph.memsz < ph.filesz)
    800050b8:	e3843603          	ld	a2,-456(s0)
    800050bc:	e3043783          	ld	a5,-464(s0)
    800050c0:	f8f669e3          	bltu	a2,a5,80005052 <exec+0x2f4>
    if(ph.vaddr + ph.memsz < ph.vaddr)
    800050c4:	e2043783          	ld	a5,-480(s0)
    800050c8:	963e                	add	a2,a2,a5
    800050ca:	f8f667e3          	bltu	a2,a5,80005058 <exec+0x2fa>
    if((sz1 = uvmalloc(pagetable, sz, ph.vaddr + ph.memsz)) == 0)
    800050ce:	85a6                	mv	a1,s1
    800050d0:	e0843503          	ld	a0,-504(s0)
    800050d4:	ffffc097          	auipc	ra,0xffffc
    800050d8:	46c080e7          	jalr	1132(ra) # 80001540 <uvmalloc>
    800050dc:	e0a43023          	sd	a0,-512(s0)
    800050e0:	dd3d                	beqz	a0,8000505e <exec+0x300>
    if(ph.vaddr % PGSIZE != 0)
    800050e2:	e2043d03          	ld	s10,-480(s0)
    800050e6:	de843783          	ld	a5,-536(s0)
    800050ea:	00fd77b3          	and	a5,s10,a5
    800050ee:	f7b1                	bnez	a5,8000503a <exec+0x2dc>
    if(loadseg(pagetable, ph.vaddr, ip, ph.off, ph.filesz) < 0)
    800050f0:	e1842d83          	lw	s11,-488(s0)
    800050f4:	e3042b83          	lw	s7,-464(s0)
  for(i = 0; i < sz; i += PGSIZE){
    800050f8:	f80b82e3          	beqz	s7,8000507c <exec+0x31e>
    800050fc:	8a5e                	mv	s4,s7
    800050fe:	4481                	li	s1,0
    80005100:	b379                	j	80004e8e <exec+0x130>

0000000080005102 <argfd>:

// Fetch the nth word-sized system call argument as a file descriptor
// and return both the descriptor and the corresponding struct file.
static int
argfd(int n, int *pfd, struct file **pf)
{
    80005102:	7179                	addi	sp,sp,-48
    80005104:	f406                	sd	ra,40(sp)
    80005106:	f022                	sd	s0,32(sp)
    80005108:	ec26                	sd	s1,24(sp)
    8000510a:	e84a                	sd	s2,16(sp)
    8000510c:	1800                	addi	s0,sp,48
    8000510e:	892e                	mv	s2,a1
    80005110:	84b2                	mv	s1,a2
  int fd;
  struct file *f;

  if(argint(n, &fd) < 0)
    80005112:	fdc40593          	addi	a1,s0,-36
    80005116:	ffffe097          	auipc	ra,0xffffe
    8000511a:	ae4080e7          	jalr	-1308(ra) # 80002bfa <argint>
    8000511e:	04054063          	bltz	a0,8000515e <argfd+0x5c>
    return -1;
  if(fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == 0)
    80005122:	fdc42703          	lw	a4,-36(s0)
    80005126:	47bd                	li	a5,15
    80005128:	02e7ed63          	bltu	a5,a4,80005162 <argfd+0x60>
    8000512c:	ffffd097          	auipc	ra,0xffffd
    80005130:	96c080e7          	jalr	-1684(ra) # 80001a98 <myproc>
    80005134:	fdc42703          	lw	a4,-36(s0)
    80005138:	01a70793          	addi	a5,a4,26
    8000513c:	078e                	slli	a5,a5,0x3
    8000513e:	953e                	add	a0,a0,a5
    80005140:	611c                	ld	a5,0(a0)
    80005142:	c395                	beqz	a5,80005166 <argfd+0x64>
    return -1;
  if(pfd)
    80005144:	00090463          	beqz	s2,8000514c <argfd+0x4a>
    *pfd = fd;
    80005148:	00e92023          	sw	a4,0(s2)
  if(pf)
    *pf = f;
  return 0;
    8000514c:	4501                	li	a0,0
  if(pf)
    8000514e:	c091                	beqz	s1,80005152 <argfd+0x50>
    *pf = f;
    80005150:	e09c                	sd	a5,0(s1)
}
    80005152:	70a2                	ld	ra,40(sp)
    80005154:	7402                	ld	s0,32(sp)
    80005156:	64e2                	ld	s1,24(sp)
    80005158:	6942                	ld	s2,16(sp)
    8000515a:	6145                	addi	sp,sp,48
    8000515c:	8082                	ret
    return -1;
    8000515e:	557d                	li	a0,-1
    80005160:	bfcd                	j	80005152 <argfd+0x50>
    return -1;
    80005162:	557d                	li	a0,-1
    80005164:	b7fd                	j	80005152 <argfd+0x50>
    80005166:	557d                	li	a0,-1
    80005168:	b7ed                	j	80005152 <argfd+0x50>

000000008000516a <fdalloc>:

// Allocate a file descriptor for the given file.
// Takes over file reference from caller on success.
static int
fdalloc(struct file *f)
{
    8000516a:	1101                	addi	sp,sp,-32
    8000516c:	ec06                	sd	ra,24(sp)
    8000516e:	e822                	sd	s0,16(sp)
    80005170:	e426                	sd	s1,8(sp)
    80005172:	1000                	addi	s0,sp,32
    80005174:	84aa                	mv	s1,a0
  int fd;
  struct proc *p = myproc();
    80005176:	ffffd097          	auipc	ra,0xffffd
    8000517a:	922080e7          	jalr	-1758(ra) # 80001a98 <myproc>

  for(fd = 0; fd < NOFILE; fd++){
    if(p->ofile[fd] == 0){
    8000517e:	697c                	ld	a5,208(a0)
    80005180:	c395                	beqz	a5,800051a4 <fdalloc+0x3a>
    80005182:	0d850713          	addi	a4,a0,216
  for(fd = 0; fd < NOFILE; fd++){
    80005186:	4785                	li	a5,1
    80005188:	4641                	li	a2,16
    if(p->ofile[fd] == 0){
    8000518a:	6314                	ld	a3,0(a4)
    8000518c:	ce89                	beqz	a3,800051a6 <fdalloc+0x3c>
  for(fd = 0; fd < NOFILE; fd++){
    8000518e:	2785                	addiw	a5,a5,1
    80005190:	0721                	addi	a4,a4,8
    80005192:	fec79ce3          	bne	a5,a2,8000518a <fdalloc+0x20>
      p->ofile[fd] = f;
      return fd;
    }
  }
  return -1;
    80005196:	57fd                	li	a5,-1
}
    80005198:	853e                	mv	a0,a5
    8000519a:	60e2                	ld	ra,24(sp)
    8000519c:	6442                	ld	s0,16(sp)
    8000519e:	64a2                	ld	s1,8(sp)
    800051a0:	6105                	addi	sp,sp,32
    800051a2:	8082                	ret
  for(fd = 0; fd < NOFILE; fd++){
    800051a4:	4781                	li	a5,0
      p->ofile[fd] = f;
    800051a6:	01a78713          	addi	a4,a5,26
    800051aa:	070e                	slli	a4,a4,0x3
    800051ac:	953a                	add	a0,a0,a4
    800051ae:	e104                	sd	s1,0(a0)
      return fd;
    800051b0:	b7e5                	j	80005198 <fdalloc+0x2e>

00000000800051b2 <create>:
  return -1;
}

static struct inode*
create(char *path, short type, short major, short minor)
{
    800051b2:	715d                	addi	sp,sp,-80
    800051b4:	e486                	sd	ra,72(sp)
    800051b6:	e0a2                	sd	s0,64(sp)
    800051b8:	fc26                	sd	s1,56(sp)
    800051ba:	f84a                	sd	s2,48(sp)
    800051bc:	f44e                	sd	s3,40(sp)
    800051be:	f052                	sd	s4,32(sp)
    800051c0:	ec56                	sd	s5,24(sp)
    800051c2:	0880                	addi	s0,sp,80
    800051c4:	89ae                	mv	s3,a1
    800051c6:	8ab2                	mv	s5,a2
    800051c8:	8a36                	mv	s4,a3
  struct inode *ip, *dp;
  char name[DIRSIZ];

  if((dp = nameiparent(path, name)) == 0)
    800051ca:	fb040593          	addi	a1,s0,-80
    800051ce:	fffff097          	auipc	ra,0xfffff
    800051d2:	dde080e7          	jalr	-546(ra) # 80003fac <nameiparent>
    800051d6:	892a                	mv	s2,a0
    800051d8:	12050f63          	beqz	a0,80005316 <create+0x164>
    return 0;

  ilock(dp);
    800051dc:	ffffe097          	auipc	ra,0xffffe
    800051e0:	5f4080e7          	jalr	1524(ra) # 800037d0 <ilock>

  if((ip = dirlookup(dp, name, 0)) != 0){
    800051e4:	4601                	li	a2,0
    800051e6:	fb040593          	addi	a1,s0,-80
    800051ea:	854a                	mv	a0,s2
    800051ec:	fffff097          	auipc	ra,0xfffff
    800051f0:	ac8080e7          	jalr	-1336(ra) # 80003cb4 <dirlookup>
    800051f4:	84aa                	mv	s1,a0
    800051f6:	c921                	beqz	a0,80005246 <create+0x94>
    iunlockput(dp);
    800051f8:	854a                	mv	a0,s2
    800051fa:	fffff097          	auipc	ra,0xfffff
    800051fe:	83a080e7          	jalr	-1990(ra) # 80003a34 <iunlockput>
    ilock(ip);
    80005202:	8526                	mv	a0,s1
    80005204:	ffffe097          	auipc	ra,0xffffe
    80005208:	5cc080e7          	jalr	1484(ra) # 800037d0 <ilock>
    if(type == T_FILE && (ip->type == T_FILE || ip->type == T_DEVICE))
    8000520c:	2981                	sext.w	s3,s3
    8000520e:	4789                	li	a5,2
    80005210:	02f99463          	bne	s3,a5,80005238 <create+0x86>
    80005214:	0444d783          	lhu	a5,68(s1)
    80005218:	37f9                	addiw	a5,a5,-2
    8000521a:	17c2                	slli	a5,a5,0x30
    8000521c:	93c1                	srli	a5,a5,0x30
    8000521e:	4705                	li	a4,1
    80005220:	00f76c63          	bltu	a4,a5,80005238 <create+0x86>
    panic("create: dirlink");

  iunlockput(dp);

  return ip;
}
    80005224:	8526                	mv	a0,s1
    80005226:	60a6                	ld	ra,72(sp)
    80005228:	6406                	ld	s0,64(sp)
    8000522a:	74e2                	ld	s1,56(sp)
    8000522c:	7942                	ld	s2,48(sp)
    8000522e:	79a2                	ld	s3,40(sp)
    80005230:	7a02                	ld	s4,32(sp)
    80005232:	6ae2                	ld	s5,24(sp)
    80005234:	6161                	addi	sp,sp,80
    80005236:	8082                	ret
    iunlockput(ip);
    80005238:	8526                	mv	a0,s1
    8000523a:	ffffe097          	auipc	ra,0xffffe
    8000523e:	7fa080e7          	jalr	2042(ra) # 80003a34 <iunlockput>
    return 0;
    80005242:	4481                	li	s1,0
    80005244:	b7c5                	j	80005224 <create+0x72>
  if((ip = ialloc(dp->dev, type)) == 0)
    80005246:	85ce                	mv	a1,s3
    80005248:	00092503          	lw	a0,0(s2)
    8000524c:	ffffe097          	auipc	ra,0xffffe
    80005250:	3e8080e7          	jalr	1000(ra) # 80003634 <ialloc>
    80005254:	84aa                	mv	s1,a0
    80005256:	c529                	beqz	a0,800052a0 <create+0xee>
  ilock(ip);
    80005258:	ffffe097          	auipc	ra,0xffffe
    8000525c:	578080e7          	jalr	1400(ra) # 800037d0 <ilock>
  ip->major = major;
    80005260:	05549323          	sh	s5,70(s1)
  ip->minor = minor;
    80005264:	05449423          	sh	s4,72(s1)
  ip->nlink = 1;
    80005268:	4785                	li	a5,1
    8000526a:	04f49523          	sh	a5,74(s1)
  iupdate(ip);
    8000526e:	8526                	mv	a0,s1
    80005270:	ffffe097          	auipc	ra,0xffffe
    80005274:	494080e7          	jalr	1172(ra) # 80003704 <iupdate>
  if(type == T_DIR){  // Create . and .. entries.
    80005278:	2981                	sext.w	s3,s3
    8000527a:	4785                	li	a5,1
    8000527c:	02f98a63          	beq	s3,a5,800052b0 <create+0xfe>
  if(dirlink(dp, name, ip->inum) < 0)
    80005280:	40d0                	lw	a2,4(s1)
    80005282:	fb040593          	addi	a1,s0,-80
    80005286:	854a                	mv	a0,s2
    80005288:	fffff097          	auipc	ra,0xfffff
    8000528c:	c44080e7          	jalr	-956(ra) # 80003ecc <dirlink>
    80005290:	06054b63          	bltz	a0,80005306 <create+0x154>
  iunlockput(dp);
    80005294:	854a                	mv	a0,s2
    80005296:	ffffe097          	auipc	ra,0xffffe
    8000529a:	79e080e7          	jalr	1950(ra) # 80003a34 <iunlockput>
  return ip;
    8000529e:	b759                	j	80005224 <create+0x72>
    panic("create: ialloc");
    800052a0:	00003517          	auipc	a0,0x3
    800052a4:	3d050513          	addi	a0,a0,976 # 80008670 <syscalls+0x2d8>
    800052a8:	ffffb097          	auipc	ra,0xffffb
    800052ac:	2cc080e7          	jalr	716(ra) # 80000574 <panic>
    dp->nlink++;  // for ".."
    800052b0:	04a95783          	lhu	a5,74(s2)
    800052b4:	2785                	addiw	a5,a5,1
    800052b6:	04f91523          	sh	a5,74(s2)
    iupdate(dp);
    800052ba:	854a                	mv	a0,s2
    800052bc:	ffffe097          	auipc	ra,0xffffe
    800052c0:	448080e7          	jalr	1096(ra) # 80003704 <iupdate>
    if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0)
    800052c4:	40d0                	lw	a2,4(s1)
    800052c6:	00003597          	auipc	a1,0x3
    800052ca:	3ba58593          	addi	a1,a1,954 # 80008680 <syscalls+0x2e8>
    800052ce:	8526                	mv	a0,s1
    800052d0:	fffff097          	auipc	ra,0xfffff
    800052d4:	bfc080e7          	jalr	-1028(ra) # 80003ecc <dirlink>
    800052d8:	00054f63          	bltz	a0,800052f6 <create+0x144>
    800052dc:	00492603          	lw	a2,4(s2)
    800052e0:	00003597          	auipc	a1,0x3
    800052e4:	3a858593          	addi	a1,a1,936 # 80008688 <syscalls+0x2f0>
    800052e8:	8526                	mv	a0,s1
    800052ea:	fffff097          	auipc	ra,0xfffff
    800052ee:	be2080e7          	jalr	-1054(ra) # 80003ecc <dirlink>
    800052f2:	f80557e3          	bgez	a0,80005280 <create+0xce>
      panic("create dots");
    800052f6:	00003517          	auipc	a0,0x3
    800052fa:	39a50513          	addi	a0,a0,922 # 80008690 <syscalls+0x2f8>
    800052fe:	ffffb097          	auipc	ra,0xffffb
    80005302:	276080e7          	jalr	630(ra) # 80000574 <panic>
    panic("create: dirlink");
    80005306:	00003517          	auipc	a0,0x3
    8000530a:	39a50513          	addi	a0,a0,922 # 800086a0 <syscalls+0x308>
    8000530e:	ffffb097          	auipc	ra,0xffffb
    80005312:	266080e7          	jalr	614(ra) # 80000574 <panic>
    return 0;
    80005316:	84aa                	mv	s1,a0
    80005318:	b731                	j	80005224 <create+0x72>

000000008000531a <sys_dup>:
{
    8000531a:	7179                	addi	sp,sp,-48
    8000531c:	f406                	sd	ra,40(sp)
    8000531e:	f022                	sd	s0,32(sp)
    80005320:	ec26                	sd	s1,24(sp)
    80005322:	1800                	addi	s0,sp,48
  if(argfd(0, 0, &f) < 0)
    80005324:	fd840613          	addi	a2,s0,-40
    80005328:	4581                	li	a1,0
    8000532a:	4501                	li	a0,0
    8000532c:	00000097          	auipc	ra,0x0
    80005330:	dd6080e7          	jalr	-554(ra) # 80005102 <argfd>
    return -1;
    80005334:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0)
    80005336:	02054363          	bltz	a0,8000535c <sys_dup+0x42>
  if((fd=fdalloc(f)) < 0)
    8000533a:	fd843503          	ld	a0,-40(s0)
    8000533e:	00000097          	auipc	ra,0x0
    80005342:	e2c080e7          	jalr	-468(ra) # 8000516a <fdalloc>
    80005346:	84aa                	mv	s1,a0
    return -1;
    80005348:	57fd                	li	a5,-1
  if((fd=fdalloc(f)) < 0)
    8000534a:	00054963          	bltz	a0,8000535c <sys_dup+0x42>
  filedup(f);
    8000534e:	fd843503          	ld	a0,-40(s0)
    80005352:	fffff097          	auipc	ra,0xfffff
    80005356:	2fa080e7          	jalr	762(ra) # 8000464c <filedup>
  return fd;
    8000535a:	87a6                	mv	a5,s1
}
    8000535c:	853e                	mv	a0,a5
    8000535e:	70a2                	ld	ra,40(sp)
    80005360:	7402                	ld	s0,32(sp)
    80005362:	64e2                	ld	s1,24(sp)
    80005364:	6145                	addi	sp,sp,48
    80005366:	8082                	ret

0000000080005368 <sys_read>:
{
    80005368:	7179                	addi	sp,sp,-48
    8000536a:	f406                	sd	ra,40(sp)
    8000536c:	f022                	sd	s0,32(sp)
    8000536e:	1800                	addi	s0,sp,48
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    80005370:	fe840613          	addi	a2,s0,-24
    80005374:	4581                	li	a1,0
    80005376:	4501                	li	a0,0
    80005378:	00000097          	auipc	ra,0x0
    8000537c:	d8a080e7          	jalr	-630(ra) # 80005102 <argfd>
    return -1;
    80005380:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    80005382:	04054163          	bltz	a0,800053c4 <sys_read+0x5c>
    80005386:	fe440593          	addi	a1,s0,-28
    8000538a:	4509                	li	a0,2
    8000538c:	ffffe097          	auipc	ra,0xffffe
    80005390:	86e080e7          	jalr	-1938(ra) # 80002bfa <argint>
    return -1;
    80005394:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    80005396:	02054763          	bltz	a0,800053c4 <sys_read+0x5c>
    8000539a:	fd840593          	addi	a1,s0,-40
    8000539e:	4505                	li	a0,1
    800053a0:	ffffe097          	auipc	ra,0xffffe
    800053a4:	87c080e7          	jalr	-1924(ra) # 80002c1c <argaddr>
    return -1;
    800053a8:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    800053aa:	00054d63          	bltz	a0,800053c4 <sys_read+0x5c>
  return fileread(f, p, n);
    800053ae:	fe442603          	lw	a2,-28(s0)
    800053b2:	fd843583          	ld	a1,-40(s0)
    800053b6:	fe843503          	ld	a0,-24(s0)
    800053ba:	fffff097          	auipc	ra,0xfffff
    800053be:	41e080e7          	jalr	1054(ra) # 800047d8 <fileread>
    800053c2:	87aa                	mv	a5,a0
}
    800053c4:	853e                	mv	a0,a5
    800053c6:	70a2                	ld	ra,40(sp)
    800053c8:	7402                	ld	s0,32(sp)
    800053ca:	6145                	addi	sp,sp,48
    800053cc:	8082                	ret

00000000800053ce <sys_write>:
{
    800053ce:	7179                	addi	sp,sp,-48
    800053d0:	f406                	sd	ra,40(sp)
    800053d2:	f022                	sd	s0,32(sp)
    800053d4:	1800                	addi	s0,sp,48
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    800053d6:	fe840613          	addi	a2,s0,-24
    800053da:	4581                	li	a1,0
    800053dc:	4501                	li	a0,0
    800053de:	00000097          	auipc	ra,0x0
    800053e2:	d24080e7          	jalr	-732(ra) # 80005102 <argfd>
    return -1;
    800053e6:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    800053e8:	04054163          	bltz	a0,8000542a <sys_write+0x5c>
    800053ec:	fe440593          	addi	a1,s0,-28
    800053f0:	4509                	li	a0,2
    800053f2:	ffffe097          	auipc	ra,0xffffe
    800053f6:	808080e7          	jalr	-2040(ra) # 80002bfa <argint>
    return -1;
    800053fa:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    800053fc:	02054763          	bltz	a0,8000542a <sys_write+0x5c>
    80005400:	fd840593          	addi	a1,s0,-40
    80005404:	4505                	li	a0,1
    80005406:	ffffe097          	auipc	ra,0xffffe
    8000540a:	816080e7          	jalr	-2026(ra) # 80002c1c <argaddr>
    return -1;
    8000540e:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    80005410:	00054d63          	bltz	a0,8000542a <sys_write+0x5c>
  return filewrite(f, p, n);
    80005414:	fe442603          	lw	a2,-28(s0)
    80005418:	fd843583          	ld	a1,-40(s0)
    8000541c:	fe843503          	ld	a0,-24(s0)
    80005420:	fffff097          	auipc	ra,0xfffff
    80005424:	47a080e7          	jalr	1146(ra) # 8000489a <filewrite>
    80005428:	87aa                	mv	a5,a0
}
    8000542a:	853e                	mv	a0,a5
    8000542c:	70a2                	ld	ra,40(sp)
    8000542e:	7402                	ld	s0,32(sp)
    80005430:	6145                	addi	sp,sp,48
    80005432:	8082                	ret

0000000080005434 <sys_close>:
{
    80005434:	1101                	addi	sp,sp,-32
    80005436:	ec06                	sd	ra,24(sp)
    80005438:	e822                	sd	s0,16(sp)
    8000543a:	1000                	addi	s0,sp,32
  if(argfd(0, &fd, &f) < 0)
    8000543c:	fe040613          	addi	a2,s0,-32
    80005440:	fec40593          	addi	a1,s0,-20
    80005444:	4501                	li	a0,0
    80005446:	00000097          	auipc	ra,0x0
    8000544a:	cbc080e7          	jalr	-836(ra) # 80005102 <argfd>
    return -1;
    8000544e:	57fd                	li	a5,-1
  if(argfd(0, &fd, &f) < 0)
    80005450:	02054463          	bltz	a0,80005478 <sys_close+0x44>
  myproc()->ofile[fd] = 0;
    80005454:	ffffc097          	auipc	ra,0xffffc
    80005458:	644080e7          	jalr	1604(ra) # 80001a98 <myproc>
    8000545c:	fec42783          	lw	a5,-20(s0)
    80005460:	07e9                	addi	a5,a5,26
    80005462:	078e                	slli	a5,a5,0x3
    80005464:	953e                	add	a0,a0,a5
    80005466:	00053023          	sd	zero,0(a0)
  fileclose(f);
    8000546a:	fe043503          	ld	a0,-32(s0)
    8000546e:	fffff097          	auipc	ra,0xfffff
    80005472:	230080e7          	jalr	560(ra) # 8000469e <fileclose>
  return 0;
    80005476:	4781                	li	a5,0
}
    80005478:	853e                	mv	a0,a5
    8000547a:	60e2                	ld	ra,24(sp)
    8000547c:	6442                	ld	s0,16(sp)
    8000547e:	6105                	addi	sp,sp,32
    80005480:	8082                	ret

0000000080005482 <sys_fstat>:
{
    80005482:	1101                	addi	sp,sp,-32
    80005484:	ec06                	sd	ra,24(sp)
    80005486:	e822                	sd	s0,16(sp)
    80005488:	1000                	addi	s0,sp,32
  if(argfd(0, 0, &f) < 0 || argaddr(1, &st) < 0)
    8000548a:	fe840613          	addi	a2,s0,-24
    8000548e:	4581                	li	a1,0
    80005490:	4501                	li	a0,0
    80005492:	00000097          	auipc	ra,0x0
    80005496:	c70080e7          	jalr	-912(ra) # 80005102 <argfd>
    return -1;
    8000549a:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argaddr(1, &st) < 0)
    8000549c:	02054563          	bltz	a0,800054c6 <sys_fstat+0x44>
    800054a0:	fe040593          	addi	a1,s0,-32
    800054a4:	4505                	li	a0,1
    800054a6:	ffffd097          	auipc	ra,0xffffd
    800054aa:	776080e7          	jalr	1910(ra) # 80002c1c <argaddr>
    return -1;
    800054ae:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argaddr(1, &st) < 0)
    800054b0:	00054b63          	bltz	a0,800054c6 <sys_fstat+0x44>
  return filestat(f, st);
    800054b4:	fe043583          	ld	a1,-32(s0)
    800054b8:	fe843503          	ld	a0,-24(s0)
    800054bc:	fffff097          	auipc	ra,0xfffff
    800054c0:	2aa080e7          	jalr	682(ra) # 80004766 <filestat>
    800054c4:	87aa                	mv	a5,a0
}
    800054c6:	853e                	mv	a0,a5
    800054c8:	60e2                	ld	ra,24(sp)
    800054ca:	6442                	ld	s0,16(sp)
    800054cc:	6105                	addi	sp,sp,32
    800054ce:	8082                	ret

00000000800054d0 <sys_link>:
{
    800054d0:	7169                	addi	sp,sp,-304
    800054d2:	f606                	sd	ra,296(sp)
    800054d4:	f222                	sd	s0,288(sp)
    800054d6:	ee26                	sd	s1,280(sp)
    800054d8:	ea4a                	sd	s2,272(sp)
    800054da:	1a00                	addi	s0,sp,304
  if(argstr(0, old, MAXPATH) < 0 || argstr(1, new, MAXPATH) < 0)
    800054dc:	08000613          	li	a2,128
    800054e0:	ed040593          	addi	a1,s0,-304
    800054e4:	4501                	li	a0,0
    800054e6:	ffffd097          	auipc	ra,0xffffd
    800054ea:	758080e7          	jalr	1880(ra) # 80002c3e <argstr>
    return -1;
    800054ee:	57fd                	li	a5,-1
  if(argstr(0, old, MAXPATH) < 0 || argstr(1, new, MAXPATH) < 0)
    800054f0:	10054e63          	bltz	a0,8000560c <sys_link+0x13c>
    800054f4:	08000613          	li	a2,128
    800054f8:	f5040593          	addi	a1,s0,-176
    800054fc:	4505                	li	a0,1
    800054fe:	ffffd097          	auipc	ra,0xffffd
    80005502:	740080e7          	jalr	1856(ra) # 80002c3e <argstr>
    return -1;
    80005506:	57fd                	li	a5,-1
  if(argstr(0, old, MAXPATH) < 0 || argstr(1, new, MAXPATH) < 0)
    80005508:	10054263          	bltz	a0,8000560c <sys_link+0x13c>
  begin_op();
    8000550c:	fffff097          	auipc	ra,0xfffff
    80005510:	c90080e7          	jalr	-880(ra) # 8000419c <begin_op>
  if((ip = namei(old)) == 0){
    80005514:	ed040513          	addi	a0,s0,-304
    80005518:	fffff097          	auipc	ra,0xfffff
    8000551c:	a76080e7          	jalr	-1418(ra) # 80003f8e <namei>
    80005520:	84aa                	mv	s1,a0
    80005522:	c551                	beqz	a0,800055ae <sys_link+0xde>
  ilock(ip);
    80005524:	ffffe097          	auipc	ra,0xffffe
    80005528:	2ac080e7          	jalr	684(ra) # 800037d0 <ilock>
  if(ip->type == T_DIR){
    8000552c:	04449703          	lh	a4,68(s1)
    80005530:	4785                	li	a5,1
    80005532:	08f70463          	beq	a4,a5,800055ba <sys_link+0xea>
  ip->nlink++;
    80005536:	04a4d783          	lhu	a5,74(s1)
    8000553a:	2785                	addiw	a5,a5,1
    8000553c:	04f49523          	sh	a5,74(s1)
  iupdate(ip);
    80005540:	8526                	mv	a0,s1
    80005542:	ffffe097          	auipc	ra,0xffffe
    80005546:	1c2080e7          	jalr	450(ra) # 80003704 <iupdate>
  iunlock(ip);
    8000554a:	8526                	mv	a0,s1
    8000554c:	ffffe097          	auipc	ra,0xffffe
    80005550:	348080e7          	jalr	840(ra) # 80003894 <iunlock>
  if((dp = nameiparent(new, name)) == 0)
    80005554:	fd040593          	addi	a1,s0,-48
    80005558:	f5040513          	addi	a0,s0,-176
    8000555c:	fffff097          	auipc	ra,0xfffff
    80005560:	a50080e7          	jalr	-1456(ra) # 80003fac <nameiparent>
    80005564:	892a                	mv	s2,a0
    80005566:	c935                	beqz	a0,800055da <sys_link+0x10a>
  ilock(dp);
    80005568:	ffffe097          	auipc	ra,0xffffe
    8000556c:	268080e7          	jalr	616(ra) # 800037d0 <ilock>
  if(dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0){
    80005570:	00092703          	lw	a4,0(s2)
    80005574:	409c                	lw	a5,0(s1)
    80005576:	04f71d63          	bne	a4,a5,800055d0 <sys_link+0x100>
    8000557a:	40d0                	lw	a2,4(s1)
    8000557c:	fd040593          	addi	a1,s0,-48
    80005580:	854a                	mv	a0,s2
    80005582:	fffff097          	auipc	ra,0xfffff
    80005586:	94a080e7          	jalr	-1718(ra) # 80003ecc <dirlink>
    8000558a:	04054363          	bltz	a0,800055d0 <sys_link+0x100>
  iunlockput(dp);
    8000558e:	854a                	mv	a0,s2
    80005590:	ffffe097          	auipc	ra,0xffffe
    80005594:	4a4080e7          	jalr	1188(ra) # 80003a34 <iunlockput>
  iput(ip);
    80005598:	8526                	mv	a0,s1
    8000559a:	ffffe097          	auipc	ra,0xffffe
    8000559e:	3f2080e7          	jalr	1010(ra) # 8000398c <iput>
  end_op();
    800055a2:	fffff097          	auipc	ra,0xfffff
    800055a6:	c7a080e7          	jalr	-902(ra) # 8000421c <end_op>
  return 0;
    800055aa:	4781                	li	a5,0
    800055ac:	a085                	j	8000560c <sys_link+0x13c>
    end_op();
    800055ae:	fffff097          	auipc	ra,0xfffff
    800055b2:	c6e080e7          	jalr	-914(ra) # 8000421c <end_op>
    return -1;
    800055b6:	57fd                	li	a5,-1
    800055b8:	a891                	j	8000560c <sys_link+0x13c>
    iunlockput(ip);
    800055ba:	8526                	mv	a0,s1
    800055bc:	ffffe097          	auipc	ra,0xffffe
    800055c0:	478080e7          	jalr	1144(ra) # 80003a34 <iunlockput>
    end_op();
    800055c4:	fffff097          	auipc	ra,0xfffff
    800055c8:	c58080e7          	jalr	-936(ra) # 8000421c <end_op>
    return -1;
    800055cc:	57fd                	li	a5,-1
    800055ce:	a83d                	j	8000560c <sys_link+0x13c>
    iunlockput(dp);
    800055d0:	854a                	mv	a0,s2
    800055d2:	ffffe097          	auipc	ra,0xffffe
    800055d6:	462080e7          	jalr	1122(ra) # 80003a34 <iunlockput>
  ilock(ip);
    800055da:	8526                	mv	a0,s1
    800055dc:	ffffe097          	auipc	ra,0xffffe
    800055e0:	1f4080e7          	jalr	500(ra) # 800037d0 <ilock>
  ip->nlink--;
    800055e4:	04a4d783          	lhu	a5,74(s1)
    800055e8:	37fd                	addiw	a5,a5,-1
    800055ea:	04f49523          	sh	a5,74(s1)
  iupdate(ip);
    800055ee:	8526                	mv	a0,s1
    800055f0:	ffffe097          	auipc	ra,0xffffe
    800055f4:	114080e7          	jalr	276(ra) # 80003704 <iupdate>
  iunlockput(ip);
    800055f8:	8526                	mv	a0,s1
    800055fa:	ffffe097          	auipc	ra,0xffffe
    800055fe:	43a080e7          	jalr	1082(ra) # 80003a34 <iunlockput>
  end_op();
    80005602:	fffff097          	auipc	ra,0xfffff
    80005606:	c1a080e7          	jalr	-998(ra) # 8000421c <end_op>
  return -1;
    8000560a:	57fd                	li	a5,-1
}
    8000560c:	853e                	mv	a0,a5
    8000560e:	70b2                	ld	ra,296(sp)
    80005610:	7412                	ld	s0,288(sp)
    80005612:	64f2                	ld	s1,280(sp)
    80005614:	6952                	ld	s2,272(sp)
    80005616:	6155                	addi	sp,sp,304
    80005618:	8082                	ret

000000008000561a <sys_unlink>:
{
    8000561a:	7151                	addi	sp,sp,-240
    8000561c:	f586                	sd	ra,232(sp)
    8000561e:	f1a2                	sd	s0,224(sp)
    80005620:	eda6                	sd	s1,216(sp)
    80005622:	e9ca                	sd	s2,208(sp)
    80005624:	e5ce                	sd	s3,200(sp)
    80005626:	1980                	addi	s0,sp,240
  if(argstr(0, path, MAXPATH) < 0)
    80005628:	08000613          	li	a2,128
    8000562c:	f3040593          	addi	a1,s0,-208
    80005630:	4501                	li	a0,0
    80005632:	ffffd097          	auipc	ra,0xffffd
    80005636:	60c080e7          	jalr	1548(ra) # 80002c3e <argstr>
    8000563a:	16054f63          	bltz	a0,800057b8 <sys_unlink+0x19e>
  begin_op();
    8000563e:	fffff097          	auipc	ra,0xfffff
    80005642:	b5e080e7          	jalr	-1186(ra) # 8000419c <begin_op>
  if((dp = nameiparent(path, name)) == 0){
    80005646:	fb040593          	addi	a1,s0,-80
    8000564a:	f3040513          	addi	a0,s0,-208
    8000564e:	fffff097          	auipc	ra,0xfffff
    80005652:	95e080e7          	jalr	-1698(ra) # 80003fac <nameiparent>
    80005656:	89aa                	mv	s3,a0
    80005658:	c979                	beqz	a0,8000572e <sys_unlink+0x114>
  ilock(dp);
    8000565a:	ffffe097          	auipc	ra,0xffffe
    8000565e:	176080e7          	jalr	374(ra) # 800037d0 <ilock>
  if(namecmp(name, ".") == 0 || namecmp(name, "..") == 0)
    80005662:	00003597          	auipc	a1,0x3
    80005666:	01e58593          	addi	a1,a1,30 # 80008680 <syscalls+0x2e8>
    8000566a:	fb040513          	addi	a0,s0,-80
    8000566e:	ffffe097          	auipc	ra,0xffffe
    80005672:	62c080e7          	jalr	1580(ra) # 80003c9a <namecmp>
    80005676:	14050863          	beqz	a0,800057c6 <sys_unlink+0x1ac>
    8000567a:	00003597          	auipc	a1,0x3
    8000567e:	00e58593          	addi	a1,a1,14 # 80008688 <syscalls+0x2f0>
    80005682:	fb040513          	addi	a0,s0,-80
    80005686:	ffffe097          	auipc	ra,0xffffe
    8000568a:	614080e7          	jalr	1556(ra) # 80003c9a <namecmp>
    8000568e:	12050c63          	beqz	a0,800057c6 <sys_unlink+0x1ac>
  if((ip = dirlookup(dp, name, &off)) == 0)
    80005692:	f2c40613          	addi	a2,s0,-212
    80005696:	fb040593          	addi	a1,s0,-80
    8000569a:	854e                	mv	a0,s3
    8000569c:	ffffe097          	auipc	ra,0xffffe
    800056a0:	618080e7          	jalr	1560(ra) # 80003cb4 <dirlookup>
    800056a4:	84aa                	mv	s1,a0
    800056a6:	12050063          	beqz	a0,800057c6 <sys_unlink+0x1ac>
  ilock(ip);
    800056aa:	ffffe097          	auipc	ra,0xffffe
    800056ae:	126080e7          	jalr	294(ra) # 800037d0 <ilock>
  if(ip->nlink < 1)
    800056b2:	04a49783          	lh	a5,74(s1)
    800056b6:	08f05263          	blez	a5,8000573a <sys_unlink+0x120>
  if(ip->type == T_DIR && !isdirempty(ip)){
    800056ba:	04449703          	lh	a4,68(s1)
    800056be:	4785                	li	a5,1
    800056c0:	08f70563          	beq	a4,a5,8000574a <sys_unlink+0x130>
  memset(&de, 0, sizeof(de));
    800056c4:	4641                	li	a2,16
    800056c6:	4581                	li	a1,0
    800056c8:	fc040513          	addi	a0,s0,-64
    800056cc:	ffffb097          	auipc	ra,0xffffb
    800056d0:	692080e7          	jalr	1682(ra) # 80000d5e <memset>
  if(writei(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    800056d4:	4741                	li	a4,16
    800056d6:	f2c42683          	lw	a3,-212(s0)
    800056da:	fc040613          	addi	a2,s0,-64
    800056de:	4581                	li	a1,0
    800056e0:	854e                	mv	a0,s3
    800056e2:	ffffe097          	auipc	ra,0xffffe
    800056e6:	49c080e7          	jalr	1180(ra) # 80003b7e <writei>
    800056ea:	47c1                	li	a5,16
    800056ec:	0af51363          	bne	a0,a5,80005792 <sys_unlink+0x178>
  if(ip->type == T_DIR){
    800056f0:	04449703          	lh	a4,68(s1)
    800056f4:	4785                	li	a5,1
    800056f6:	0af70663          	beq	a4,a5,800057a2 <sys_unlink+0x188>
  iunlockput(dp);
    800056fa:	854e                	mv	a0,s3
    800056fc:	ffffe097          	auipc	ra,0xffffe
    80005700:	338080e7          	jalr	824(ra) # 80003a34 <iunlockput>
  ip->nlink--;
    80005704:	04a4d783          	lhu	a5,74(s1)
    80005708:	37fd                	addiw	a5,a5,-1
    8000570a:	04f49523          	sh	a5,74(s1)
  iupdate(ip);
    8000570e:	8526                	mv	a0,s1
    80005710:	ffffe097          	auipc	ra,0xffffe
    80005714:	ff4080e7          	jalr	-12(ra) # 80003704 <iupdate>
  iunlockput(ip);
    80005718:	8526                	mv	a0,s1
    8000571a:	ffffe097          	auipc	ra,0xffffe
    8000571e:	31a080e7          	jalr	794(ra) # 80003a34 <iunlockput>
  end_op();
    80005722:	fffff097          	auipc	ra,0xfffff
    80005726:	afa080e7          	jalr	-1286(ra) # 8000421c <end_op>
  return 0;
    8000572a:	4501                	li	a0,0
    8000572c:	a07d                	j	800057da <sys_unlink+0x1c0>
    end_op();
    8000572e:	fffff097          	auipc	ra,0xfffff
    80005732:	aee080e7          	jalr	-1298(ra) # 8000421c <end_op>
    return -1;
    80005736:	557d                	li	a0,-1
    80005738:	a04d                	j	800057da <sys_unlink+0x1c0>
    panic("unlink: nlink < 1");
    8000573a:	00003517          	auipc	a0,0x3
    8000573e:	f7650513          	addi	a0,a0,-138 # 800086b0 <syscalls+0x318>
    80005742:	ffffb097          	auipc	ra,0xffffb
    80005746:	e32080e7          	jalr	-462(ra) # 80000574 <panic>
  for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){
    8000574a:	44f8                	lw	a4,76(s1)
    8000574c:	02000793          	li	a5,32
    80005750:	f6e7fae3          	bleu	a4,a5,800056c4 <sys_unlink+0xaa>
    80005754:	02000913          	li	s2,32
    if(readi(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    80005758:	4741                	li	a4,16
    8000575a:	86ca                	mv	a3,s2
    8000575c:	f1840613          	addi	a2,s0,-232
    80005760:	4581                	li	a1,0
    80005762:	8526                	mv	a0,s1
    80005764:	ffffe097          	auipc	ra,0xffffe
    80005768:	322080e7          	jalr	802(ra) # 80003a86 <readi>
    8000576c:	47c1                	li	a5,16
    8000576e:	00f51a63          	bne	a0,a5,80005782 <sys_unlink+0x168>
    if(de.inum != 0)
    80005772:	f1845783          	lhu	a5,-232(s0)
    80005776:	e3b9                	bnez	a5,800057bc <sys_unlink+0x1a2>
  for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){
    80005778:	2941                	addiw	s2,s2,16
    8000577a:	44fc                	lw	a5,76(s1)
    8000577c:	fcf96ee3          	bltu	s2,a5,80005758 <sys_unlink+0x13e>
    80005780:	b791                	j	800056c4 <sys_unlink+0xaa>
      panic("isdirempty: readi");
    80005782:	00003517          	auipc	a0,0x3
    80005786:	f4650513          	addi	a0,a0,-186 # 800086c8 <syscalls+0x330>
    8000578a:	ffffb097          	auipc	ra,0xffffb
    8000578e:	dea080e7          	jalr	-534(ra) # 80000574 <panic>
    panic("unlink: writei");
    80005792:	00003517          	auipc	a0,0x3
    80005796:	f4e50513          	addi	a0,a0,-178 # 800086e0 <syscalls+0x348>
    8000579a:	ffffb097          	auipc	ra,0xffffb
    8000579e:	dda080e7          	jalr	-550(ra) # 80000574 <panic>
    dp->nlink--;
    800057a2:	04a9d783          	lhu	a5,74(s3)
    800057a6:	37fd                	addiw	a5,a5,-1
    800057a8:	04f99523          	sh	a5,74(s3)
    iupdate(dp);
    800057ac:	854e                	mv	a0,s3
    800057ae:	ffffe097          	auipc	ra,0xffffe
    800057b2:	f56080e7          	jalr	-170(ra) # 80003704 <iupdate>
    800057b6:	b791                	j	800056fa <sys_unlink+0xe0>
    return -1;
    800057b8:	557d                	li	a0,-1
    800057ba:	a005                	j	800057da <sys_unlink+0x1c0>
    iunlockput(ip);
    800057bc:	8526                	mv	a0,s1
    800057be:	ffffe097          	auipc	ra,0xffffe
    800057c2:	276080e7          	jalr	630(ra) # 80003a34 <iunlockput>
  iunlockput(dp);
    800057c6:	854e                	mv	a0,s3
    800057c8:	ffffe097          	auipc	ra,0xffffe
    800057cc:	26c080e7          	jalr	620(ra) # 80003a34 <iunlockput>
  end_op();
    800057d0:	fffff097          	auipc	ra,0xfffff
    800057d4:	a4c080e7          	jalr	-1460(ra) # 8000421c <end_op>
  return -1;
    800057d8:	557d                	li	a0,-1
}
    800057da:	70ae                	ld	ra,232(sp)
    800057dc:	740e                	ld	s0,224(sp)
    800057de:	64ee                	ld	s1,216(sp)
    800057e0:	694e                	ld	s2,208(sp)
    800057e2:	69ae                	ld	s3,200(sp)
    800057e4:	616d                	addi	sp,sp,240
    800057e6:	8082                	ret

00000000800057e8 <sys_open>:

uint64
sys_open(void)
{
    800057e8:	7131                	addi	sp,sp,-192
    800057ea:	fd06                	sd	ra,184(sp)
    800057ec:	f922                	sd	s0,176(sp)
    800057ee:	f526                	sd	s1,168(sp)
    800057f0:	f14a                	sd	s2,160(sp)
    800057f2:	ed4e                	sd	s3,152(sp)
    800057f4:	0180                	addi	s0,sp,192
  int fd, omode;
  struct file *f;
  struct inode *ip;
  int n;

  if((n = argstr(0, path, MAXPATH)) < 0 || argint(1, &omode) < 0)
    800057f6:	08000613          	li	a2,128
    800057fa:	f5040593          	addi	a1,s0,-176
    800057fe:	4501                	li	a0,0
    80005800:	ffffd097          	auipc	ra,0xffffd
    80005804:	43e080e7          	jalr	1086(ra) # 80002c3e <argstr>
    return -1;
    80005808:	54fd                	li	s1,-1
  if((n = argstr(0, path, MAXPATH)) < 0 || argint(1, &omode) < 0)
    8000580a:	0c054163          	bltz	a0,800058cc <sys_open+0xe4>
    8000580e:	f4c40593          	addi	a1,s0,-180
    80005812:	4505                	li	a0,1
    80005814:	ffffd097          	auipc	ra,0xffffd
    80005818:	3e6080e7          	jalr	998(ra) # 80002bfa <argint>
    8000581c:	0a054863          	bltz	a0,800058cc <sys_open+0xe4>

  begin_op();
    80005820:	fffff097          	auipc	ra,0xfffff
    80005824:	97c080e7          	jalr	-1668(ra) # 8000419c <begin_op>

  if(omode & O_CREATE){
    80005828:	f4c42783          	lw	a5,-180(s0)
    8000582c:	2007f793          	andi	a5,a5,512
    80005830:	cbdd                	beqz	a5,800058e6 <sys_open+0xfe>
    ip = create(path, T_FILE, 0, 0);
    80005832:	4681                	li	a3,0
    80005834:	4601                	li	a2,0
    80005836:	4589                	li	a1,2
    80005838:	f5040513          	addi	a0,s0,-176
    8000583c:	00000097          	auipc	ra,0x0
    80005840:	976080e7          	jalr	-1674(ra) # 800051b2 <create>
    80005844:	892a                	mv	s2,a0
    if(ip == 0){
    80005846:	c959                	beqz	a0,800058dc <sys_open+0xf4>
      end_op();
      return -1;
    }
  }

  if(ip->type == T_DEVICE && (ip->major < 0 || ip->major >= NDEV)){
    80005848:	04491703          	lh	a4,68(s2)
    8000584c:	478d                	li	a5,3
    8000584e:	00f71763          	bne	a4,a5,8000585c <sys_open+0x74>
    80005852:	04695703          	lhu	a4,70(s2)
    80005856:	47a5                	li	a5,9
    80005858:	0ce7ec63          	bltu	a5,a4,80005930 <sys_open+0x148>
    iunlockput(ip);
    end_op();
    return -1;
  }

  if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){
    8000585c:	fffff097          	auipc	ra,0xfffff
    80005860:	d72080e7          	jalr	-654(ra) # 800045ce <filealloc>
    80005864:	89aa                	mv	s3,a0
    80005866:	10050263          	beqz	a0,8000596a <sys_open+0x182>
    8000586a:	00000097          	auipc	ra,0x0
    8000586e:	900080e7          	jalr	-1792(ra) # 8000516a <fdalloc>
    80005872:	84aa                	mv	s1,a0
    80005874:	0e054663          	bltz	a0,80005960 <sys_open+0x178>
    iunlockput(ip);
    end_op();
    return -1;
  }

  if(ip->type == T_DEVICE){
    80005878:	04491703          	lh	a4,68(s2)
    8000587c:	478d                	li	a5,3
    8000587e:	0cf70463          	beq	a4,a5,80005946 <sys_open+0x15e>
    f->type = FD_DEVICE;
    f->major = ip->major;
  } else {
    f->type = FD_INODE;
    80005882:	4789                	li	a5,2
    80005884:	00f9a023          	sw	a5,0(s3)
    f->off = 0;
    80005888:	0209a023          	sw	zero,32(s3)
  }
  f->ip = ip;
    8000588c:	0129bc23          	sd	s2,24(s3)
  f->readable = !(omode & O_WRONLY);
    80005890:	f4c42783          	lw	a5,-180(s0)
    80005894:	0017c713          	xori	a4,a5,1
    80005898:	8b05                	andi	a4,a4,1
    8000589a:	00e98423          	sb	a4,8(s3)
  f->writable = (omode & O_WRONLY) || (omode & O_RDWR);
    8000589e:	0037f713          	andi	a4,a5,3
    800058a2:	00e03733          	snez	a4,a4
    800058a6:	00e984a3          	sb	a4,9(s3)

  if((omode & O_TRUNC) && ip->type == T_FILE){
    800058aa:	4007f793          	andi	a5,a5,1024
    800058ae:	c791                	beqz	a5,800058ba <sys_open+0xd2>
    800058b0:	04491703          	lh	a4,68(s2)
    800058b4:	4789                	li	a5,2
    800058b6:	08f70f63          	beq	a4,a5,80005954 <sys_open+0x16c>
    itrunc(ip);
  }

  iunlock(ip);
    800058ba:	854a                	mv	a0,s2
    800058bc:	ffffe097          	auipc	ra,0xffffe
    800058c0:	fd8080e7          	jalr	-40(ra) # 80003894 <iunlock>
  end_op();
    800058c4:	fffff097          	auipc	ra,0xfffff
    800058c8:	958080e7          	jalr	-1704(ra) # 8000421c <end_op>

  return fd;
}
    800058cc:	8526                	mv	a0,s1
    800058ce:	70ea                	ld	ra,184(sp)
    800058d0:	744a                	ld	s0,176(sp)
    800058d2:	74aa                	ld	s1,168(sp)
    800058d4:	790a                	ld	s2,160(sp)
    800058d6:	69ea                	ld	s3,152(sp)
    800058d8:	6129                	addi	sp,sp,192
    800058da:	8082                	ret
      end_op();
    800058dc:	fffff097          	auipc	ra,0xfffff
    800058e0:	940080e7          	jalr	-1728(ra) # 8000421c <end_op>
      return -1;
    800058e4:	b7e5                	j	800058cc <sys_open+0xe4>
    if((ip = namei(path)) == 0){
    800058e6:	f5040513          	addi	a0,s0,-176
    800058ea:	ffffe097          	auipc	ra,0xffffe
    800058ee:	6a4080e7          	jalr	1700(ra) # 80003f8e <namei>
    800058f2:	892a                	mv	s2,a0
    800058f4:	c905                	beqz	a0,80005924 <sys_open+0x13c>
    ilock(ip);
    800058f6:	ffffe097          	auipc	ra,0xffffe
    800058fa:	eda080e7          	jalr	-294(ra) # 800037d0 <ilock>
    if(ip->type == T_DIR && omode != O_RDONLY){
    800058fe:	04491703          	lh	a4,68(s2)
    80005902:	4785                	li	a5,1
    80005904:	f4f712e3          	bne	a4,a5,80005848 <sys_open+0x60>
    80005908:	f4c42783          	lw	a5,-180(s0)
    8000590c:	dba1                	beqz	a5,8000585c <sys_open+0x74>
      iunlockput(ip);
    8000590e:	854a                	mv	a0,s2
    80005910:	ffffe097          	auipc	ra,0xffffe
    80005914:	124080e7          	jalr	292(ra) # 80003a34 <iunlockput>
      end_op();
    80005918:	fffff097          	auipc	ra,0xfffff
    8000591c:	904080e7          	jalr	-1788(ra) # 8000421c <end_op>
      return -1;
    80005920:	54fd                	li	s1,-1
    80005922:	b76d                	j	800058cc <sys_open+0xe4>
      end_op();
    80005924:	fffff097          	auipc	ra,0xfffff
    80005928:	8f8080e7          	jalr	-1800(ra) # 8000421c <end_op>
      return -1;
    8000592c:	54fd                	li	s1,-1
    8000592e:	bf79                	j	800058cc <sys_open+0xe4>
    iunlockput(ip);
    80005930:	854a                	mv	a0,s2
    80005932:	ffffe097          	auipc	ra,0xffffe
    80005936:	102080e7          	jalr	258(ra) # 80003a34 <iunlockput>
    end_op();
    8000593a:	fffff097          	auipc	ra,0xfffff
    8000593e:	8e2080e7          	jalr	-1822(ra) # 8000421c <end_op>
    return -1;
    80005942:	54fd                	li	s1,-1
    80005944:	b761                	j	800058cc <sys_open+0xe4>
    f->type = FD_DEVICE;
    80005946:	00f9a023          	sw	a5,0(s3)
    f->major = ip->major;
    8000594a:	04691783          	lh	a5,70(s2)
    8000594e:	02f99223          	sh	a5,36(s3)
    80005952:	bf2d                	j	8000588c <sys_open+0xa4>
    itrunc(ip);
    80005954:	854a                	mv	a0,s2
    80005956:	ffffe097          	auipc	ra,0xffffe
    8000595a:	f8a080e7          	jalr	-118(ra) # 800038e0 <itrunc>
    8000595e:	bfb1                	j	800058ba <sys_open+0xd2>
      fileclose(f);
    80005960:	854e                	mv	a0,s3
    80005962:	fffff097          	auipc	ra,0xfffff
    80005966:	d3c080e7          	jalr	-708(ra) # 8000469e <fileclose>
    iunlockput(ip);
    8000596a:	854a                	mv	a0,s2
    8000596c:	ffffe097          	auipc	ra,0xffffe
    80005970:	0c8080e7          	jalr	200(ra) # 80003a34 <iunlockput>
    end_op();
    80005974:	fffff097          	auipc	ra,0xfffff
    80005978:	8a8080e7          	jalr	-1880(ra) # 8000421c <end_op>
    return -1;
    8000597c:	54fd                	li	s1,-1
    8000597e:	b7b9                	j	800058cc <sys_open+0xe4>

0000000080005980 <sys_mkdir>:

uint64
sys_mkdir(void)
{
    80005980:	7175                	addi	sp,sp,-144
    80005982:	e506                	sd	ra,136(sp)
    80005984:	e122                	sd	s0,128(sp)
    80005986:	0900                	addi	s0,sp,144
  char path[MAXPATH];
  struct inode *ip;

  begin_op();
    80005988:	fffff097          	auipc	ra,0xfffff
    8000598c:	814080e7          	jalr	-2028(ra) # 8000419c <begin_op>
  if(argstr(0, path, MAXPATH) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0){
    80005990:	08000613          	li	a2,128
    80005994:	f7040593          	addi	a1,s0,-144
    80005998:	4501                	li	a0,0
    8000599a:	ffffd097          	auipc	ra,0xffffd
    8000599e:	2a4080e7          	jalr	676(ra) # 80002c3e <argstr>
    800059a2:	02054963          	bltz	a0,800059d4 <sys_mkdir+0x54>
    800059a6:	4681                	li	a3,0
    800059a8:	4601                	li	a2,0
    800059aa:	4585                	li	a1,1
    800059ac:	f7040513          	addi	a0,s0,-144
    800059b0:	00000097          	auipc	ra,0x0
    800059b4:	802080e7          	jalr	-2046(ra) # 800051b2 <create>
    800059b8:	cd11                	beqz	a0,800059d4 <sys_mkdir+0x54>
    end_op();
    return -1;
  }
  iunlockput(ip);
    800059ba:	ffffe097          	auipc	ra,0xffffe
    800059be:	07a080e7          	jalr	122(ra) # 80003a34 <iunlockput>
  end_op();
    800059c2:	fffff097          	auipc	ra,0xfffff
    800059c6:	85a080e7          	jalr	-1958(ra) # 8000421c <end_op>
  return 0;
    800059ca:	4501                	li	a0,0
}
    800059cc:	60aa                	ld	ra,136(sp)
    800059ce:	640a                	ld	s0,128(sp)
    800059d0:	6149                	addi	sp,sp,144
    800059d2:	8082                	ret
    end_op();
    800059d4:	fffff097          	auipc	ra,0xfffff
    800059d8:	848080e7          	jalr	-1976(ra) # 8000421c <end_op>
    return -1;
    800059dc:	557d                	li	a0,-1
    800059de:	b7fd                	j	800059cc <sys_mkdir+0x4c>

00000000800059e0 <sys_mknod>:

uint64
sys_mknod(void)
{
    800059e0:	7135                	addi	sp,sp,-160
    800059e2:	ed06                	sd	ra,152(sp)
    800059e4:	e922                	sd	s0,144(sp)
    800059e6:	1100                	addi	s0,sp,160
  struct inode *ip;
  char path[MAXPATH];
  int major, minor;

  begin_op();
    800059e8:	ffffe097          	auipc	ra,0xffffe
    800059ec:	7b4080e7          	jalr	1972(ra) # 8000419c <begin_op>
  if((argstr(0, path, MAXPATH)) < 0 ||
    800059f0:	08000613          	li	a2,128
    800059f4:	f7040593          	addi	a1,s0,-144
    800059f8:	4501                	li	a0,0
    800059fa:	ffffd097          	auipc	ra,0xffffd
    800059fe:	244080e7          	jalr	580(ra) # 80002c3e <argstr>
    80005a02:	04054a63          	bltz	a0,80005a56 <sys_mknod+0x76>
     argint(1, &major) < 0 ||
    80005a06:	f6c40593          	addi	a1,s0,-148
    80005a0a:	4505                	li	a0,1
    80005a0c:	ffffd097          	auipc	ra,0xffffd
    80005a10:	1ee080e7          	jalr	494(ra) # 80002bfa <argint>
  if((argstr(0, path, MAXPATH)) < 0 ||
    80005a14:	04054163          	bltz	a0,80005a56 <sys_mknod+0x76>
     argint(2, &minor) < 0 ||
    80005a18:	f6840593          	addi	a1,s0,-152
    80005a1c:	4509                	li	a0,2
    80005a1e:	ffffd097          	auipc	ra,0xffffd
    80005a22:	1dc080e7          	jalr	476(ra) # 80002bfa <argint>
     argint(1, &major) < 0 ||
    80005a26:	02054863          	bltz	a0,80005a56 <sys_mknod+0x76>
     (ip = create(path, T_DEVICE, major, minor)) == 0){
    80005a2a:	f6841683          	lh	a3,-152(s0)
    80005a2e:	f6c41603          	lh	a2,-148(s0)
    80005a32:	458d                	li	a1,3
    80005a34:	f7040513          	addi	a0,s0,-144
    80005a38:	fffff097          	auipc	ra,0xfffff
    80005a3c:	77a080e7          	jalr	1914(ra) # 800051b2 <create>
     argint(2, &minor) < 0 ||
    80005a40:	c919                	beqz	a0,80005a56 <sys_mknod+0x76>
    end_op();
    return -1;
  }
  iunlockput(ip);
    80005a42:	ffffe097          	auipc	ra,0xffffe
    80005a46:	ff2080e7          	jalr	-14(ra) # 80003a34 <iunlockput>
  end_op();
    80005a4a:	ffffe097          	auipc	ra,0xffffe
    80005a4e:	7d2080e7          	jalr	2002(ra) # 8000421c <end_op>
  return 0;
    80005a52:	4501                	li	a0,0
    80005a54:	a031                	j	80005a60 <sys_mknod+0x80>
    end_op();
    80005a56:	ffffe097          	auipc	ra,0xffffe
    80005a5a:	7c6080e7          	jalr	1990(ra) # 8000421c <end_op>
    return -1;
    80005a5e:	557d                	li	a0,-1
}
    80005a60:	60ea                	ld	ra,152(sp)
    80005a62:	644a                	ld	s0,144(sp)
    80005a64:	610d                	addi	sp,sp,160
    80005a66:	8082                	ret

0000000080005a68 <sys_chdir>:

uint64
sys_chdir(void)
{
    80005a68:	7135                	addi	sp,sp,-160
    80005a6a:	ed06                	sd	ra,152(sp)
    80005a6c:	e922                	sd	s0,144(sp)
    80005a6e:	e526                	sd	s1,136(sp)
    80005a70:	e14a                	sd	s2,128(sp)
    80005a72:	1100                	addi	s0,sp,160
  char path[MAXPATH];
  struct inode *ip;
  struct proc *p = myproc();
    80005a74:	ffffc097          	auipc	ra,0xffffc
    80005a78:	024080e7          	jalr	36(ra) # 80001a98 <myproc>
    80005a7c:	892a                	mv	s2,a0
  
  begin_op();
    80005a7e:	ffffe097          	auipc	ra,0xffffe
    80005a82:	71e080e7          	jalr	1822(ra) # 8000419c <begin_op>
  if(argstr(0, path, MAXPATH) < 0 || (ip = namei(path)) == 0){
    80005a86:	08000613          	li	a2,128
    80005a8a:	f6040593          	addi	a1,s0,-160
    80005a8e:	4501                	li	a0,0
    80005a90:	ffffd097          	auipc	ra,0xffffd
    80005a94:	1ae080e7          	jalr	430(ra) # 80002c3e <argstr>
    80005a98:	04054b63          	bltz	a0,80005aee <sys_chdir+0x86>
    80005a9c:	f6040513          	addi	a0,s0,-160
    80005aa0:	ffffe097          	auipc	ra,0xffffe
    80005aa4:	4ee080e7          	jalr	1262(ra) # 80003f8e <namei>
    80005aa8:	84aa                	mv	s1,a0
    80005aaa:	c131                	beqz	a0,80005aee <sys_chdir+0x86>
    end_op();
    return -1;
  }
  ilock(ip);
    80005aac:	ffffe097          	auipc	ra,0xffffe
    80005ab0:	d24080e7          	jalr	-732(ra) # 800037d0 <ilock>
  if(ip->type != T_DIR){
    80005ab4:	04449703          	lh	a4,68(s1)
    80005ab8:	4785                	li	a5,1
    80005aba:	04f71063          	bne	a4,a5,80005afa <sys_chdir+0x92>
    iunlockput(ip);
    end_op();
    return -1;
  }
  iunlock(ip);
    80005abe:	8526                	mv	a0,s1
    80005ac0:	ffffe097          	auipc	ra,0xffffe
    80005ac4:	dd4080e7          	jalr	-556(ra) # 80003894 <iunlock>
  iput(p->cwd);
    80005ac8:	15093503          	ld	a0,336(s2)
    80005acc:	ffffe097          	auipc	ra,0xffffe
    80005ad0:	ec0080e7          	jalr	-320(ra) # 8000398c <iput>
  end_op();
    80005ad4:	ffffe097          	auipc	ra,0xffffe
    80005ad8:	748080e7          	jalr	1864(ra) # 8000421c <end_op>
  p->cwd = ip;
    80005adc:	14993823          	sd	s1,336(s2)
  return 0;
    80005ae0:	4501                	li	a0,0
}
    80005ae2:	60ea                	ld	ra,152(sp)
    80005ae4:	644a                	ld	s0,144(sp)
    80005ae6:	64aa                	ld	s1,136(sp)
    80005ae8:	690a                	ld	s2,128(sp)
    80005aea:	610d                	addi	sp,sp,160
    80005aec:	8082                	ret
    end_op();
    80005aee:	ffffe097          	auipc	ra,0xffffe
    80005af2:	72e080e7          	jalr	1838(ra) # 8000421c <end_op>
    return -1;
    80005af6:	557d                	li	a0,-1
    80005af8:	b7ed                	j	80005ae2 <sys_chdir+0x7a>
    iunlockput(ip);
    80005afa:	8526                	mv	a0,s1
    80005afc:	ffffe097          	auipc	ra,0xffffe
    80005b00:	f38080e7          	jalr	-200(ra) # 80003a34 <iunlockput>
    end_op();
    80005b04:	ffffe097          	auipc	ra,0xffffe
    80005b08:	718080e7          	jalr	1816(ra) # 8000421c <end_op>
    return -1;
    80005b0c:	557d                	li	a0,-1
    80005b0e:	bfd1                	j	80005ae2 <sys_chdir+0x7a>

0000000080005b10 <sys_exec>:

uint64
sys_exec(void)
{
    80005b10:	7145                	addi	sp,sp,-464
    80005b12:	e786                	sd	ra,456(sp)
    80005b14:	e3a2                	sd	s0,448(sp)
    80005b16:	ff26                	sd	s1,440(sp)
    80005b18:	fb4a                	sd	s2,432(sp)
    80005b1a:	f74e                	sd	s3,424(sp)
    80005b1c:	f352                	sd	s4,416(sp)
    80005b1e:	ef56                	sd	s5,408(sp)
    80005b20:	0b80                	addi	s0,sp,464
  char path[MAXPATH], *argv[MAXARG];
  int i;
  uint64 uargv, uarg;

  if(argstr(0, path, MAXPATH) < 0 || argaddr(1, &uargv) < 0){
    80005b22:	08000613          	li	a2,128
    80005b26:	f4040593          	addi	a1,s0,-192
    80005b2a:	4501                	li	a0,0
    80005b2c:	ffffd097          	auipc	ra,0xffffd
    80005b30:	112080e7          	jalr	274(ra) # 80002c3e <argstr>
    return -1;
    80005b34:	597d                	li	s2,-1
  if(argstr(0, path, MAXPATH) < 0 || argaddr(1, &uargv) < 0){
    80005b36:	0e054c63          	bltz	a0,80005c2e <sys_exec+0x11e>
    80005b3a:	e3840593          	addi	a1,s0,-456
    80005b3e:	4505                	li	a0,1
    80005b40:	ffffd097          	auipc	ra,0xffffd
    80005b44:	0dc080e7          	jalr	220(ra) # 80002c1c <argaddr>
    80005b48:	0e054363          	bltz	a0,80005c2e <sys_exec+0x11e>
  }
  memset(argv, 0, sizeof(argv));
    80005b4c:	e4040913          	addi	s2,s0,-448
    80005b50:	10000613          	li	a2,256
    80005b54:	4581                	li	a1,0
    80005b56:	854a                	mv	a0,s2
    80005b58:	ffffb097          	auipc	ra,0xffffb
    80005b5c:	206080e7          	jalr	518(ra) # 80000d5e <memset>
  for(i=0;; i++){
    if(i >= NELEM(argv)){
    80005b60:	89ca                	mv	s3,s2
  memset(argv, 0, sizeof(argv));
    80005b62:	4481                	li	s1,0
    if(i >= NELEM(argv)){
    80005b64:	02000a93          	li	s5,32
    80005b68:	00048a1b          	sext.w	s4,s1
      goto bad;
    }
    if(fetchaddr(uargv+sizeof(uint64)*i, (uint64*)&uarg) < 0){
    80005b6c:	00349513          	slli	a0,s1,0x3
    80005b70:	e3040593          	addi	a1,s0,-464
    80005b74:	e3843783          	ld	a5,-456(s0)
    80005b78:	953e                	add	a0,a0,a5
    80005b7a:	ffffd097          	auipc	ra,0xffffd
    80005b7e:	fe4080e7          	jalr	-28(ra) # 80002b5e <fetchaddr>
    80005b82:	02054a63          	bltz	a0,80005bb6 <sys_exec+0xa6>
      goto bad;
    }
    if(uarg == 0){
    80005b86:	e3043783          	ld	a5,-464(s0)
    80005b8a:	cfa9                	beqz	a5,80005be4 <sys_exec+0xd4>
      argv[i] = 0;
      break;
    }
    argv[i] = kalloc();
    80005b8c:	ffffb097          	auipc	ra,0xffffb
    80005b90:	fe6080e7          	jalr	-26(ra) # 80000b72 <kalloc>
    80005b94:	00a93023          	sd	a0,0(s2)
    if(argv[i] == 0)
    80005b98:	cd19                	beqz	a0,80005bb6 <sys_exec+0xa6>
      goto bad;
    if(fetchstr(uarg, argv[i], PGSIZE) < 0)
    80005b9a:	6605                	lui	a2,0x1
    80005b9c:	85aa                	mv	a1,a0
    80005b9e:	e3043503          	ld	a0,-464(s0)
    80005ba2:	ffffd097          	auipc	ra,0xffffd
    80005ba6:	010080e7          	jalr	16(ra) # 80002bb2 <fetchstr>
    80005baa:	00054663          	bltz	a0,80005bb6 <sys_exec+0xa6>
    if(i >= NELEM(argv)){
    80005bae:	0485                	addi	s1,s1,1
    80005bb0:	0921                	addi	s2,s2,8
    80005bb2:	fb549be3          	bne	s1,s5,80005b68 <sys_exec+0x58>
    kfree(argv[i]);

  return ret;

 bad:
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80005bb6:	e4043503          	ld	a0,-448(s0)
    kfree(argv[i]);
  return -1;
    80005bba:	597d                	li	s2,-1
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80005bbc:	c92d                	beqz	a0,80005c2e <sys_exec+0x11e>
    kfree(argv[i]);
    80005bbe:	ffffb097          	auipc	ra,0xffffb
    80005bc2:	eb4080e7          	jalr	-332(ra) # 80000a72 <kfree>
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80005bc6:	e4840493          	addi	s1,s0,-440
    80005bca:	10098993          	addi	s3,s3,256
    80005bce:	6088                	ld	a0,0(s1)
    80005bd0:	cd31                	beqz	a0,80005c2c <sys_exec+0x11c>
    kfree(argv[i]);
    80005bd2:	ffffb097          	auipc	ra,0xffffb
    80005bd6:	ea0080e7          	jalr	-352(ra) # 80000a72 <kfree>
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80005bda:	04a1                	addi	s1,s1,8
    80005bdc:	ff3499e3          	bne	s1,s3,80005bce <sys_exec+0xbe>
  return -1;
    80005be0:	597d                	li	s2,-1
    80005be2:	a0b1                	j	80005c2e <sys_exec+0x11e>
      argv[i] = 0;
    80005be4:	0a0e                	slli	s4,s4,0x3
    80005be6:	fc040793          	addi	a5,s0,-64
    80005bea:	9a3e                	add	s4,s4,a5
    80005bec:	e80a3023          	sd	zero,-384(s4)
  int ret = exec(path, argv);
    80005bf0:	e4040593          	addi	a1,s0,-448
    80005bf4:	f4040513          	addi	a0,s0,-192
    80005bf8:	fffff097          	auipc	ra,0xfffff
    80005bfc:	166080e7          	jalr	358(ra) # 80004d5e <exec>
    80005c00:	892a                	mv	s2,a0
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80005c02:	e4043503          	ld	a0,-448(s0)
    80005c06:	c505                	beqz	a0,80005c2e <sys_exec+0x11e>
    kfree(argv[i]);
    80005c08:	ffffb097          	auipc	ra,0xffffb
    80005c0c:	e6a080e7          	jalr	-406(ra) # 80000a72 <kfree>
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80005c10:	e4840493          	addi	s1,s0,-440
    80005c14:	10098993          	addi	s3,s3,256
    80005c18:	6088                	ld	a0,0(s1)
    80005c1a:	c911                	beqz	a0,80005c2e <sys_exec+0x11e>
    kfree(argv[i]);
    80005c1c:	ffffb097          	auipc	ra,0xffffb
    80005c20:	e56080e7          	jalr	-426(ra) # 80000a72 <kfree>
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80005c24:	04a1                	addi	s1,s1,8
    80005c26:	ff3499e3          	bne	s1,s3,80005c18 <sys_exec+0x108>
    80005c2a:	a011                	j	80005c2e <sys_exec+0x11e>
  return -1;
    80005c2c:	597d                	li	s2,-1
}
    80005c2e:	854a                	mv	a0,s2
    80005c30:	60be                	ld	ra,456(sp)
    80005c32:	641e                	ld	s0,448(sp)
    80005c34:	74fa                	ld	s1,440(sp)
    80005c36:	795a                	ld	s2,432(sp)
    80005c38:	79ba                	ld	s3,424(sp)
    80005c3a:	7a1a                	ld	s4,416(sp)
    80005c3c:	6afa                	ld	s5,408(sp)
    80005c3e:	6179                	addi	sp,sp,464
    80005c40:	8082                	ret

0000000080005c42 <sys_pipe>:

uint64
sys_pipe(void)
{
    80005c42:	7139                	addi	sp,sp,-64
    80005c44:	fc06                	sd	ra,56(sp)
    80005c46:	f822                	sd	s0,48(sp)
    80005c48:	f426                	sd	s1,40(sp)
    80005c4a:	0080                	addi	s0,sp,64
  uint64 fdarray; // user pointer to array of two integers
  struct file *rf, *wf;
  int fd0, fd1;
  struct proc *p = myproc();
    80005c4c:	ffffc097          	auipc	ra,0xffffc
    80005c50:	e4c080e7          	jalr	-436(ra) # 80001a98 <myproc>
    80005c54:	84aa                	mv	s1,a0

  if(argaddr(0, &fdarray) < 0)
    80005c56:	fd840593          	addi	a1,s0,-40
    80005c5a:	4501                	li	a0,0
    80005c5c:	ffffd097          	auipc	ra,0xffffd
    80005c60:	fc0080e7          	jalr	-64(ra) # 80002c1c <argaddr>
    return -1;
    80005c64:	57fd                	li	a5,-1
  if(argaddr(0, &fdarray) < 0)
    80005c66:	0c054f63          	bltz	a0,80005d44 <sys_pipe+0x102>
  if(pipealloc(&rf, &wf) < 0)
    80005c6a:	fc840593          	addi	a1,s0,-56
    80005c6e:	fd040513          	addi	a0,s0,-48
    80005c72:	fffff097          	auipc	ra,0xfffff
    80005c76:	d74080e7          	jalr	-652(ra) # 800049e6 <pipealloc>
    return -1;
    80005c7a:	57fd                	li	a5,-1
  if(pipealloc(&rf, &wf) < 0)
    80005c7c:	0c054463          	bltz	a0,80005d44 <sys_pipe+0x102>
  fd0 = -1;
    80005c80:	fcf42223          	sw	a5,-60(s0)
  if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){
    80005c84:	fd043503          	ld	a0,-48(s0)
    80005c88:	fffff097          	auipc	ra,0xfffff
    80005c8c:	4e2080e7          	jalr	1250(ra) # 8000516a <fdalloc>
    80005c90:	fca42223          	sw	a0,-60(s0)
    80005c94:	08054b63          	bltz	a0,80005d2a <sys_pipe+0xe8>
    80005c98:	fc843503          	ld	a0,-56(s0)
    80005c9c:	fffff097          	auipc	ra,0xfffff
    80005ca0:	4ce080e7          	jalr	1230(ra) # 8000516a <fdalloc>
    80005ca4:	fca42023          	sw	a0,-64(s0)
    80005ca8:	06054863          	bltz	a0,80005d18 <sys_pipe+0xd6>
      p->ofile[fd0] = 0;
    fileclose(rf);
    fileclose(wf);
    return -1;
  }
  if(copyout(p->pagetable, fdarray, (char*)&fd0, sizeof(fd0)) < 0 ||
    80005cac:	4691                	li	a3,4
    80005cae:	fc440613          	addi	a2,s0,-60
    80005cb2:	fd843583          	ld	a1,-40(s0)
    80005cb6:	68a8                	ld	a0,80(s1)
    80005cb8:	ffffc097          	auipc	ra,0xffffc
    80005cbc:	abc080e7          	jalr	-1348(ra) # 80001774 <copyout>
    80005cc0:	02054063          	bltz	a0,80005ce0 <sys_pipe+0x9e>
     copyout(p->pagetable, fdarray+sizeof(fd0), (char *)&fd1, sizeof(fd1)) < 0){
    80005cc4:	4691                	li	a3,4
    80005cc6:	fc040613          	addi	a2,s0,-64
    80005cca:	fd843583          	ld	a1,-40(s0)
    80005cce:	0591                	addi	a1,a1,4
    80005cd0:	68a8                	ld	a0,80(s1)
    80005cd2:	ffffc097          	auipc	ra,0xffffc
    80005cd6:	aa2080e7          	jalr	-1374(ra) # 80001774 <copyout>
    p->ofile[fd1] = 0;
    fileclose(rf);
    fileclose(wf);
    return -1;
  }
  return 0;
    80005cda:	4781                	li	a5,0
  if(copyout(p->pagetable, fdarray, (char*)&fd0, sizeof(fd0)) < 0 ||
    80005cdc:	06055463          	bgez	a0,80005d44 <sys_pipe+0x102>
    p->ofile[fd0] = 0;
    80005ce0:	fc442783          	lw	a5,-60(s0)
    80005ce4:	07e9                	addi	a5,a5,26
    80005ce6:	078e                	slli	a5,a5,0x3
    80005ce8:	97a6                	add	a5,a5,s1
    80005cea:	0007b023          	sd	zero,0(a5)
    p->ofile[fd1] = 0;
    80005cee:	fc042783          	lw	a5,-64(s0)
    80005cf2:	07e9                	addi	a5,a5,26
    80005cf4:	078e                	slli	a5,a5,0x3
    80005cf6:	94be                	add	s1,s1,a5
    80005cf8:	0004b023          	sd	zero,0(s1)
    fileclose(rf);
    80005cfc:	fd043503          	ld	a0,-48(s0)
    80005d00:	fffff097          	auipc	ra,0xfffff
    80005d04:	99e080e7          	jalr	-1634(ra) # 8000469e <fileclose>
    fileclose(wf);
    80005d08:	fc843503          	ld	a0,-56(s0)
    80005d0c:	fffff097          	auipc	ra,0xfffff
    80005d10:	992080e7          	jalr	-1646(ra) # 8000469e <fileclose>
    return -1;
    80005d14:	57fd                	li	a5,-1
    80005d16:	a03d                	j	80005d44 <sys_pipe+0x102>
    if(fd0 >= 0)
    80005d18:	fc442783          	lw	a5,-60(s0)
    80005d1c:	0007c763          	bltz	a5,80005d2a <sys_pipe+0xe8>
      p->ofile[fd0] = 0;
    80005d20:	07e9                	addi	a5,a5,26
    80005d22:	078e                	slli	a5,a5,0x3
    80005d24:	94be                	add	s1,s1,a5
    80005d26:	0004b023          	sd	zero,0(s1)
    fileclose(rf);
    80005d2a:	fd043503          	ld	a0,-48(s0)
    80005d2e:	fffff097          	auipc	ra,0xfffff
    80005d32:	970080e7          	jalr	-1680(ra) # 8000469e <fileclose>
    fileclose(wf);
    80005d36:	fc843503          	ld	a0,-56(s0)
    80005d3a:	fffff097          	auipc	ra,0xfffff
    80005d3e:	964080e7          	jalr	-1692(ra) # 8000469e <fileclose>
    return -1;
    80005d42:	57fd                	li	a5,-1
}
    80005d44:	853e                	mv	a0,a5
    80005d46:	70e2                	ld	ra,56(sp)
    80005d48:	7442                	ld	s0,48(sp)
    80005d4a:	74a2                	ld	s1,40(sp)
    80005d4c:	6121                	addi	sp,sp,64
    80005d4e:	8082                	ret

0000000080005d50 <kernelvec>:
    80005d50:	7111                	addi	sp,sp,-256
    80005d52:	e006                	sd	ra,0(sp)
    80005d54:	e40a                	sd	sp,8(sp)
    80005d56:	e80e                	sd	gp,16(sp)
    80005d58:	ec12                	sd	tp,24(sp)
    80005d5a:	f016                	sd	t0,32(sp)
    80005d5c:	f41a                	sd	t1,40(sp)
    80005d5e:	f81e                	sd	t2,48(sp)
    80005d60:	fc22                	sd	s0,56(sp)
    80005d62:	e0a6                	sd	s1,64(sp)
    80005d64:	e4aa                	sd	a0,72(sp)
    80005d66:	e8ae                	sd	a1,80(sp)
    80005d68:	ecb2                	sd	a2,88(sp)
    80005d6a:	f0b6                	sd	a3,96(sp)
    80005d6c:	f4ba                	sd	a4,104(sp)
    80005d6e:	f8be                	sd	a5,112(sp)
    80005d70:	fcc2                	sd	a6,120(sp)
    80005d72:	e146                	sd	a7,128(sp)
    80005d74:	e54a                	sd	s2,136(sp)
    80005d76:	e94e                	sd	s3,144(sp)
    80005d78:	ed52                	sd	s4,152(sp)
    80005d7a:	f156                	sd	s5,160(sp)
    80005d7c:	f55a                	sd	s6,168(sp)
    80005d7e:	f95e                	sd	s7,176(sp)
    80005d80:	fd62                	sd	s8,184(sp)
    80005d82:	e1e6                	sd	s9,192(sp)
    80005d84:	e5ea                	sd	s10,200(sp)
    80005d86:	e9ee                	sd	s11,208(sp)
    80005d88:	edf2                	sd	t3,216(sp)
    80005d8a:	f1f6                	sd	t4,224(sp)
    80005d8c:	f5fa                	sd	t5,232(sp)
    80005d8e:	f9fe                	sd	t6,240(sp)
    80005d90:	c97fc0ef          	jal	ra,80002a26 <kerneltrap>
    80005d94:	6082                	ld	ra,0(sp)
    80005d96:	6122                	ld	sp,8(sp)
    80005d98:	61c2                	ld	gp,16(sp)
    80005d9a:	7282                	ld	t0,32(sp)
    80005d9c:	7322                	ld	t1,40(sp)
    80005d9e:	73c2                	ld	t2,48(sp)
    80005da0:	7462                	ld	s0,56(sp)
    80005da2:	6486                	ld	s1,64(sp)
    80005da4:	6526                	ld	a0,72(sp)
    80005da6:	65c6                	ld	a1,80(sp)
    80005da8:	6666                	ld	a2,88(sp)
    80005daa:	7686                	ld	a3,96(sp)
    80005dac:	7726                	ld	a4,104(sp)
    80005dae:	77c6                	ld	a5,112(sp)
    80005db0:	7866                	ld	a6,120(sp)
    80005db2:	688a                	ld	a7,128(sp)
    80005db4:	692a                	ld	s2,136(sp)
    80005db6:	69ca                	ld	s3,144(sp)
    80005db8:	6a6a                	ld	s4,152(sp)
    80005dba:	7a8a                	ld	s5,160(sp)
    80005dbc:	7b2a                	ld	s6,168(sp)
    80005dbe:	7bca                	ld	s7,176(sp)
    80005dc0:	7c6a                	ld	s8,184(sp)
    80005dc2:	6c8e                	ld	s9,192(sp)
    80005dc4:	6d2e                	ld	s10,200(sp)
    80005dc6:	6dce                	ld	s11,208(sp)
    80005dc8:	6e6e                	ld	t3,216(sp)
    80005dca:	7e8e                	ld	t4,224(sp)
    80005dcc:	7f2e                	ld	t5,232(sp)
    80005dce:	7fce                	ld	t6,240(sp)
    80005dd0:	6111                	addi	sp,sp,256
    80005dd2:	10200073          	sret
    80005dd6:	00000013          	nop
    80005dda:	00000013          	nop
    80005dde:	0001                	nop

0000000080005de0 <timervec>:
    80005de0:	34051573          	csrrw	a0,mscratch,a0
    80005de4:	e10c                	sd	a1,0(a0)
    80005de6:	e510                	sd	a2,8(a0)
    80005de8:	e914                	sd	a3,16(a0)
    80005dea:	710c                	ld	a1,32(a0)
    80005dec:	7510                	ld	a2,40(a0)
    80005dee:	6194                	ld	a3,0(a1)
    80005df0:	96b2                	add	a3,a3,a2
    80005df2:	e194                	sd	a3,0(a1)
    80005df4:	4589                	li	a1,2
    80005df6:	14459073          	csrw	sip,a1
    80005dfa:	6914                	ld	a3,16(a0)
    80005dfc:	6510                	ld	a2,8(a0)
    80005dfe:	610c                	ld	a1,0(a0)
    80005e00:	34051573          	csrrw	a0,mscratch,a0
    80005e04:	30200073          	mret
	...

0000000080005e0a <plicinit>:
// the riscv Platform Level Interrupt Controller (PLIC).
//

void
plicinit(void)
{
    80005e0a:	1141                	addi	sp,sp,-16
    80005e0c:	e422                	sd	s0,8(sp)
    80005e0e:	0800                	addi	s0,sp,16
  // set desired IRQ priorities non-zero (otherwise disabled).
  *(uint32*)(PLIC + UART0_IRQ*4) = 1;
    80005e10:	0c0007b7          	lui	a5,0xc000
    80005e14:	4705                	li	a4,1
    80005e16:	d798                	sw	a4,40(a5)
  *(uint32*)(PLIC + VIRTIO0_IRQ*4) = 1;
    80005e18:	c3d8                	sw	a4,4(a5)
}
    80005e1a:	6422                	ld	s0,8(sp)
    80005e1c:	0141                	addi	sp,sp,16
    80005e1e:	8082                	ret

0000000080005e20 <plicinithart>:

void
plicinithart(void)
{
    80005e20:	1141                	addi	sp,sp,-16
    80005e22:	e406                	sd	ra,8(sp)
    80005e24:	e022                	sd	s0,0(sp)
    80005e26:	0800                	addi	s0,sp,16
  int hart = cpuid();
    80005e28:	ffffc097          	auipc	ra,0xffffc
    80005e2c:	c44080e7          	jalr	-956(ra) # 80001a6c <cpuid>
  
  // set uart's enable bit for this hart's S-mode. 
  *(uint32*)PLIC_SENABLE(hart)= (1 << UART0_IRQ) | (1 << VIRTIO0_IRQ);
    80005e30:	0085171b          	slliw	a4,a0,0x8
    80005e34:	0c0027b7          	lui	a5,0xc002
    80005e38:	97ba                	add	a5,a5,a4
    80005e3a:	40200713          	li	a4,1026
    80005e3e:	08e7a023          	sw	a4,128(a5) # c002080 <_entry-0x73ffdf80>

  // set this hart's S-mode priority threshold to 0.
  *(uint32*)PLIC_SPRIORITY(hart) = 0;
    80005e42:	00d5151b          	slliw	a0,a0,0xd
    80005e46:	0c2017b7          	lui	a5,0xc201
    80005e4a:	953e                	add	a0,a0,a5
    80005e4c:	00052023          	sw	zero,0(a0)
}
    80005e50:	60a2                	ld	ra,8(sp)
    80005e52:	6402                	ld	s0,0(sp)
    80005e54:	0141                	addi	sp,sp,16
    80005e56:	8082                	ret

0000000080005e58 <plic_claim>:

// ask the PLIC what interrupt we should serve.
int
plic_claim(void)
{
    80005e58:	1141                	addi	sp,sp,-16
    80005e5a:	e406                	sd	ra,8(sp)
    80005e5c:	e022                	sd	s0,0(sp)
    80005e5e:	0800                	addi	s0,sp,16
  int hart = cpuid();
    80005e60:	ffffc097          	auipc	ra,0xffffc
    80005e64:	c0c080e7          	jalr	-1012(ra) # 80001a6c <cpuid>
  int irq = *(uint32*)PLIC_SCLAIM(hart);
    80005e68:	00d5151b          	slliw	a0,a0,0xd
    80005e6c:	0c2017b7          	lui	a5,0xc201
    80005e70:	97aa                	add	a5,a5,a0
  return irq;
}
    80005e72:	43c8                	lw	a0,4(a5)
    80005e74:	60a2                	ld	ra,8(sp)
    80005e76:	6402                	ld	s0,0(sp)
    80005e78:	0141                	addi	sp,sp,16
    80005e7a:	8082                	ret

0000000080005e7c <plic_complete>:

// tell the PLIC we've served this IRQ.
void
plic_complete(int irq)
{
    80005e7c:	1101                	addi	sp,sp,-32
    80005e7e:	ec06                	sd	ra,24(sp)
    80005e80:	e822                	sd	s0,16(sp)
    80005e82:	e426                	sd	s1,8(sp)
    80005e84:	1000                	addi	s0,sp,32
    80005e86:	84aa                	mv	s1,a0
  int hart = cpuid();
    80005e88:	ffffc097          	auipc	ra,0xffffc
    80005e8c:	be4080e7          	jalr	-1052(ra) # 80001a6c <cpuid>
  *(uint32*)PLIC_SCLAIM(hart) = irq;
    80005e90:	00d5151b          	slliw	a0,a0,0xd
    80005e94:	0c2017b7          	lui	a5,0xc201
    80005e98:	97aa                	add	a5,a5,a0
    80005e9a:	c3c4                	sw	s1,4(a5)
}
    80005e9c:	60e2                	ld	ra,24(sp)
    80005e9e:	6442                	ld	s0,16(sp)
    80005ea0:	64a2                	ld	s1,8(sp)
    80005ea2:	6105                	addi	sp,sp,32
    80005ea4:	8082                	ret

0000000080005ea6 <free_desc>:
}

// mark a descriptor as free.
static void
free_desc(int i)
{
    80005ea6:	1141                	addi	sp,sp,-16
    80005ea8:	e406                	sd	ra,8(sp)
    80005eaa:	e022                	sd	s0,0(sp)
    80005eac:	0800                	addi	s0,sp,16
  if(i >= NUM)
    80005eae:	479d                	li	a5,7
    80005eb0:	04a7cd63          	blt	a5,a0,80005f0a <free_desc+0x64>
    panic("virtio_disk_intr 1");
  if(disk.free[i])
    80005eb4:	0001d797          	auipc	a5,0x1d
    80005eb8:	14c78793          	addi	a5,a5,332 # 80023000 <disk>
    80005ebc:	00a78733          	add	a4,a5,a0
    80005ec0:	6789                	lui	a5,0x2
    80005ec2:	97ba                	add	a5,a5,a4
    80005ec4:	0187c783          	lbu	a5,24(a5) # 2018 <_entry-0x7fffdfe8>
    80005ec8:	eba9                	bnez	a5,80005f1a <free_desc+0x74>
    panic("virtio_disk_intr 2");
  disk.desc[i].addr = 0;
    80005eca:	0001f797          	auipc	a5,0x1f
    80005ece:	13678793          	addi	a5,a5,310 # 80025000 <disk+0x2000>
    80005ed2:	639c                	ld	a5,0(a5)
    80005ed4:	00451713          	slli	a4,a0,0x4
    80005ed8:	97ba                	add	a5,a5,a4
    80005eda:	0007b023          	sd	zero,0(a5)
  disk.free[i] = 1;
    80005ede:	0001d797          	auipc	a5,0x1d
    80005ee2:	12278793          	addi	a5,a5,290 # 80023000 <disk>
    80005ee6:	97aa                	add	a5,a5,a0
    80005ee8:	6509                	lui	a0,0x2
    80005eea:	953e                	add	a0,a0,a5
    80005eec:	4785                	li	a5,1
    80005eee:	00f50c23          	sb	a5,24(a0) # 2018 <_entry-0x7fffdfe8>
  wakeup(&disk.free[0]);
    80005ef2:	0001f517          	auipc	a0,0x1f
    80005ef6:	12650513          	addi	a0,a0,294 # 80025018 <disk+0x2018>
    80005efa:	ffffc097          	auipc	ra,0xffffc
    80005efe:	53e080e7          	jalr	1342(ra) # 80002438 <wakeup>
}
    80005f02:	60a2                	ld	ra,8(sp)
    80005f04:	6402                	ld	s0,0(sp)
    80005f06:	0141                	addi	sp,sp,16
    80005f08:	8082                	ret
    panic("virtio_disk_intr 1");
    80005f0a:	00002517          	auipc	a0,0x2
    80005f0e:	7e650513          	addi	a0,a0,2022 # 800086f0 <syscalls+0x358>
    80005f12:	ffffa097          	auipc	ra,0xffffa
    80005f16:	662080e7          	jalr	1634(ra) # 80000574 <panic>
    panic("virtio_disk_intr 2");
    80005f1a:	00002517          	auipc	a0,0x2
    80005f1e:	7ee50513          	addi	a0,a0,2030 # 80008708 <syscalls+0x370>
    80005f22:	ffffa097          	auipc	ra,0xffffa
    80005f26:	652080e7          	jalr	1618(ra) # 80000574 <panic>

0000000080005f2a <virtio_disk_init>:
{
    80005f2a:	1101                	addi	sp,sp,-32
    80005f2c:	ec06                	sd	ra,24(sp)
    80005f2e:	e822                	sd	s0,16(sp)
    80005f30:	e426                	sd	s1,8(sp)
    80005f32:	1000                	addi	s0,sp,32
  initlock(&disk.vdisk_lock, "virtio_disk");
    80005f34:	00002597          	auipc	a1,0x2
    80005f38:	7ec58593          	addi	a1,a1,2028 # 80008720 <syscalls+0x388>
    80005f3c:	0001f517          	auipc	a0,0x1f
    80005f40:	16c50513          	addi	a0,a0,364 # 800250a8 <disk+0x20a8>
    80005f44:	ffffb097          	auipc	ra,0xffffb
    80005f48:	c8e080e7          	jalr	-882(ra) # 80000bd2 <initlock>
  if(*R(VIRTIO_MMIO_MAGIC_VALUE) != 0x74726976 ||
    80005f4c:	100017b7          	lui	a5,0x10001
    80005f50:	4398                	lw	a4,0(a5)
    80005f52:	2701                	sext.w	a4,a4
    80005f54:	747277b7          	lui	a5,0x74727
    80005f58:	97678793          	addi	a5,a5,-1674 # 74726976 <_entry-0xb8d968a>
    80005f5c:	0ef71163          	bne	a4,a5,8000603e <virtio_disk_init+0x114>
     *R(VIRTIO_MMIO_VERSION) != 1 ||
    80005f60:	100017b7          	lui	a5,0x10001
    80005f64:	43dc                	lw	a5,4(a5)
    80005f66:	2781                	sext.w	a5,a5
  if(*R(VIRTIO_MMIO_MAGIC_VALUE) != 0x74726976 ||
    80005f68:	4705                	li	a4,1
    80005f6a:	0ce79a63          	bne	a5,a4,8000603e <virtio_disk_init+0x114>
     *R(VIRTIO_MMIO_DEVICE_ID) != 2 ||
    80005f6e:	100017b7          	lui	a5,0x10001
    80005f72:	479c                	lw	a5,8(a5)
    80005f74:	2781                	sext.w	a5,a5
     *R(VIRTIO_MMIO_VERSION) != 1 ||
    80005f76:	4709                	li	a4,2
    80005f78:	0ce79363          	bne	a5,a4,8000603e <virtio_disk_init+0x114>
     *R(VIRTIO_MMIO_VENDOR_ID) != 0x554d4551){
    80005f7c:	100017b7          	lui	a5,0x10001
    80005f80:	47d8                	lw	a4,12(a5)
    80005f82:	2701                	sext.w	a4,a4
     *R(VIRTIO_MMIO_DEVICE_ID) != 2 ||
    80005f84:	554d47b7          	lui	a5,0x554d4
    80005f88:	55178793          	addi	a5,a5,1361 # 554d4551 <_entry-0x2ab2baaf>
    80005f8c:	0af71963          	bne	a4,a5,8000603e <virtio_disk_init+0x114>
  *R(VIRTIO_MMIO_STATUS) = status;
    80005f90:	100017b7          	lui	a5,0x10001
    80005f94:	4705                	li	a4,1
    80005f96:	dbb8                	sw	a4,112(a5)
  *R(VIRTIO_MMIO_STATUS) = status;
    80005f98:	470d                	li	a4,3
    80005f9a:	dbb8                	sw	a4,112(a5)
  uint64 features = *R(VIRTIO_MMIO_DEVICE_FEATURES);
    80005f9c:	4b94                	lw	a3,16(a5)
  features &= ~(1 << VIRTIO_RING_F_INDIRECT_DESC);
    80005f9e:	c7ffe737          	lui	a4,0xc7ffe
    80005fa2:	75f70713          	addi	a4,a4,1887 # ffffffffc7ffe75f <end+0xffffffff47fd875f>
    80005fa6:	8f75                	and	a4,a4,a3
  *R(VIRTIO_MMIO_DRIVER_FEATURES) = features;
    80005fa8:	2701                	sext.w	a4,a4
    80005faa:	d398                	sw	a4,32(a5)
  *R(VIRTIO_MMIO_STATUS) = status;
    80005fac:	472d                	li	a4,11
    80005fae:	dbb8                	sw	a4,112(a5)
  *R(VIRTIO_MMIO_STATUS) = status;
    80005fb0:	473d                	li	a4,15
    80005fb2:	dbb8                	sw	a4,112(a5)
  *R(VIRTIO_MMIO_GUEST_PAGE_SIZE) = PGSIZE;
    80005fb4:	6705                	lui	a4,0x1
    80005fb6:	d798                	sw	a4,40(a5)
  *R(VIRTIO_MMIO_QUEUE_SEL) = 0;
    80005fb8:	0207a823          	sw	zero,48(a5) # 10001030 <_entry-0x6fffefd0>
  uint32 max = *R(VIRTIO_MMIO_QUEUE_NUM_MAX);
    80005fbc:	5bdc                	lw	a5,52(a5)
    80005fbe:	2781                	sext.w	a5,a5
  if(max == 0)
    80005fc0:	c7d9                	beqz	a5,8000604e <virtio_disk_init+0x124>
  if(max < NUM)
    80005fc2:	471d                	li	a4,7
    80005fc4:	08f77d63          	bleu	a5,a4,8000605e <virtio_disk_init+0x134>
  *R(VIRTIO_MMIO_QUEUE_NUM) = NUM;
    80005fc8:	100014b7          	lui	s1,0x10001
    80005fcc:	47a1                	li	a5,8
    80005fce:	dc9c                	sw	a5,56(s1)
  memset(disk.pages, 0, sizeof(disk.pages));
    80005fd0:	6609                	lui	a2,0x2
    80005fd2:	4581                	li	a1,0
    80005fd4:	0001d517          	auipc	a0,0x1d
    80005fd8:	02c50513          	addi	a0,a0,44 # 80023000 <disk>
    80005fdc:	ffffb097          	auipc	ra,0xffffb
    80005fe0:	d82080e7          	jalr	-638(ra) # 80000d5e <memset>
  *R(VIRTIO_MMIO_QUEUE_PFN) = ((uint64)disk.pages) >> PGSHIFT;
    80005fe4:	0001d717          	auipc	a4,0x1d
    80005fe8:	01c70713          	addi	a4,a4,28 # 80023000 <disk>
    80005fec:	00c75793          	srli	a5,a4,0xc
    80005ff0:	2781                	sext.w	a5,a5
    80005ff2:	c0bc                	sw	a5,64(s1)
  disk.desc = (struct VRingDesc *) disk.pages;
    80005ff4:	0001f797          	auipc	a5,0x1f
    80005ff8:	00c78793          	addi	a5,a5,12 # 80025000 <disk+0x2000>
    80005ffc:	e398                	sd	a4,0(a5)
  disk.avail = (uint16*)(((char*)disk.desc) + NUM*sizeof(struct VRingDesc));
    80005ffe:	0001d717          	auipc	a4,0x1d
    80006002:	08270713          	addi	a4,a4,130 # 80023080 <disk+0x80>
    80006006:	e798                	sd	a4,8(a5)
  disk.used = (struct UsedArea *) (disk.pages + PGSIZE);
    80006008:	0001e717          	auipc	a4,0x1e
    8000600c:	ff870713          	addi	a4,a4,-8 # 80024000 <disk+0x1000>
    80006010:	eb98                	sd	a4,16(a5)
    disk.free[i] = 1;
    80006012:	4705                	li	a4,1
    80006014:	00e78c23          	sb	a4,24(a5)
    80006018:	00e78ca3          	sb	a4,25(a5)
    8000601c:	00e78d23          	sb	a4,26(a5)
    80006020:	00e78da3          	sb	a4,27(a5)
    80006024:	00e78e23          	sb	a4,28(a5)
    80006028:	00e78ea3          	sb	a4,29(a5)
    8000602c:	00e78f23          	sb	a4,30(a5)
    80006030:	00e78fa3          	sb	a4,31(a5)
}
    80006034:	60e2                	ld	ra,24(sp)
    80006036:	6442                	ld	s0,16(sp)
    80006038:	64a2                	ld	s1,8(sp)
    8000603a:	6105                	addi	sp,sp,32
    8000603c:	8082                	ret
    panic("could not find virtio disk");
    8000603e:	00002517          	auipc	a0,0x2
    80006042:	6f250513          	addi	a0,a0,1778 # 80008730 <syscalls+0x398>
    80006046:	ffffa097          	auipc	ra,0xffffa
    8000604a:	52e080e7          	jalr	1326(ra) # 80000574 <panic>
    panic("virtio disk has no queue 0");
    8000604e:	00002517          	auipc	a0,0x2
    80006052:	70250513          	addi	a0,a0,1794 # 80008750 <syscalls+0x3b8>
    80006056:	ffffa097          	auipc	ra,0xffffa
    8000605a:	51e080e7          	jalr	1310(ra) # 80000574 <panic>
    panic("virtio disk max queue too short");
    8000605e:	00002517          	auipc	a0,0x2
    80006062:	71250513          	addi	a0,a0,1810 # 80008770 <syscalls+0x3d8>
    80006066:	ffffa097          	auipc	ra,0xffffa
    8000606a:	50e080e7          	jalr	1294(ra) # 80000574 <panic>

000000008000606e <virtio_disk_rw>:
  return 0;
}

void
virtio_disk_rw(struct buf *b, int write)
{
    8000606e:	7159                	addi	sp,sp,-112
    80006070:	f486                	sd	ra,104(sp)
    80006072:	f0a2                	sd	s0,96(sp)
    80006074:	eca6                	sd	s1,88(sp)
    80006076:	e8ca                	sd	s2,80(sp)
    80006078:	e4ce                	sd	s3,72(sp)
    8000607a:	e0d2                	sd	s4,64(sp)
    8000607c:	fc56                	sd	s5,56(sp)
    8000607e:	f85a                	sd	s6,48(sp)
    80006080:	f45e                	sd	s7,40(sp)
    80006082:	f062                	sd	s8,32(sp)
    80006084:	1880                	addi	s0,sp,112
    80006086:	892a                	mv	s2,a0
    80006088:	8c2e                	mv	s8,a1
  uint64 sector = b->blockno * (BSIZE / 512);
    8000608a:	00c52b83          	lw	s7,12(a0)
    8000608e:	001b9b9b          	slliw	s7,s7,0x1
    80006092:	1b82                	slli	s7,s7,0x20
    80006094:	020bdb93          	srli	s7,s7,0x20

  acquire(&disk.vdisk_lock);
    80006098:	0001f517          	auipc	a0,0x1f
    8000609c:	01050513          	addi	a0,a0,16 # 800250a8 <disk+0x20a8>
    800060a0:	ffffb097          	auipc	ra,0xffffb
    800060a4:	bc2080e7          	jalr	-1086(ra) # 80000c62 <acquire>
    if(disk.free[i]){
    800060a8:	0001f997          	auipc	s3,0x1f
    800060ac:	f5898993          	addi	s3,s3,-168 # 80025000 <disk+0x2000>
  for(int i = 0; i < NUM; i++){
    800060b0:	4b21                	li	s6,8
      disk.free[i] = 0;
    800060b2:	0001da97          	auipc	s5,0x1d
    800060b6:	f4ea8a93          	addi	s5,s5,-178 # 80023000 <disk>
  for(int i = 0; i < 3; i++){
    800060ba:	4a0d                	li	s4,3
    800060bc:	a079                	j	8000614a <virtio_disk_rw+0xdc>
      disk.free[i] = 0;
    800060be:	00fa86b3          	add	a3,s5,a5
    800060c2:	96ae                	add	a3,a3,a1
    800060c4:	00068c23          	sb	zero,24(a3)
    idx[i] = alloc_desc();
    800060c8:	c21c                	sw	a5,0(a2)
    if(idx[i] < 0){
    800060ca:	0207ca63          	bltz	a5,800060fe <virtio_disk_rw+0x90>
  for(int i = 0; i < 3; i++){
    800060ce:	2485                	addiw	s1,s1,1
    800060d0:	0711                	addi	a4,a4,4
    800060d2:	25448163          	beq	s1,s4,80006314 <virtio_disk_rw+0x2a6>
    idx[i] = alloc_desc();
    800060d6:	863a                	mv	a2,a4
    if(disk.free[i]){
    800060d8:	0189c783          	lbu	a5,24(s3)
    800060dc:	24079163          	bnez	a5,8000631e <virtio_disk_rw+0x2b0>
    800060e0:	0001f697          	auipc	a3,0x1f
    800060e4:	f3968693          	addi	a3,a3,-199 # 80025019 <disk+0x2019>
  for(int i = 0; i < NUM; i++){
    800060e8:	87aa                	mv	a5,a0
    if(disk.free[i]){
    800060ea:	0006c803          	lbu	a6,0(a3)
    800060ee:	fc0818e3          	bnez	a6,800060be <virtio_disk_rw+0x50>
  for(int i = 0; i < NUM; i++){
    800060f2:	2785                	addiw	a5,a5,1
    800060f4:	0685                	addi	a3,a3,1
    800060f6:	ff679ae3          	bne	a5,s6,800060ea <virtio_disk_rw+0x7c>
    idx[i] = alloc_desc();
    800060fa:	57fd                	li	a5,-1
    800060fc:	c21c                	sw	a5,0(a2)
      for(int j = 0; j < i; j++)
    800060fe:	02905a63          	blez	s1,80006132 <virtio_disk_rw+0xc4>
        free_desc(idx[j]);
    80006102:	fa042503          	lw	a0,-96(s0)
    80006106:	00000097          	auipc	ra,0x0
    8000610a:	da0080e7          	jalr	-608(ra) # 80005ea6 <free_desc>
      for(int j = 0; j < i; j++)
    8000610e:	4785                	li	a5,1
    80006110:	0297d163          	ble	s1,a5,80006132 <virtio_disk_rw+0xc4>
        free_desc(idx[j]);
    80006114:	fa442503          	lw	a0,-92(s0)
    80006118:	00000097          	auipc	ra,0x0
    8000611c:	d8e080e7          	jalr	-626(ra) # 80005ea6 <free_desc>
      for(int j = 0; j < i; j++)
    80006120:	4789                	li	a5,2
    80006122:	0097d863          	ble	s1,a5,80006132 <virtio_disk_rw+0xc4>
        free_desc(idx[j]);
    80006126:	fa842503          	lw	a0,-88(s0)
    8000612a:	00000097          	auipc	ra,0x0
    8000612e:	d7c080e7          	jalr	-644(ra) # 80005ea6 <free_desc>
  int idx[3];
  while(1){
    if(alloc3_desc(idx) == 0) {
      break;
    }
    sleep(&disk.free[0], &disk.vdisk_lock);
    80006132:	0001f597          	auipc	a1,0x1f
    80006136:	f7658593          	addi	a1,a1,-138 # 800250a8 <disk+0x20a8>
    8000613a:	0001f517          	auipc	a0,0x1f
    8000613e:	ede50513          	addi	a0,a0,-290 # 80025018 <disk+0x2018>
    80006142:	ffffc097          	auipc	ra,0xffffc
    80006146:	170080e7          	jalr	368(ra) # 800022b2 <sleep>
  for(int i = 0; i < 3; i++){
    8000614a:	fa040713          	addi	a4,s0,-96
    8000614e:	4481                	li	s1,0
  for(int i = 0; i < NUM; i++){
    80006150:	4505                	li	a0,1
      disk.free[i] = 0;
    80006152:	6589                	lui	a1,0x2
    80006154:	b749                	j	800060d6 <virtio_disk_rw+0x68>
    uint32 reserved;
    uint64 sector;
  } buf0;

  if(write)
    buf0.type = VIRTIO_BLK_T_OUT; // write the disk
    80006156:	4785                	li	a5,1
    80006158:	f8f42823          	sw	a5,-112(s0)
  else
    buf0.type = VIRTIO_BLK_T_IN; // read the disk
  buf0.reserved = 0;
    8000615c:	f8042a23          	sw	zero,-108(s0)
  buf0.sector = sector;
    80006160:	f9743c23          	sd	s7,-104(s0)

  // buf0 is on a kernel stack, which is not direct mapped,
  // thus the call to kvmpa().
  disk.desc[idx[0]].addr = (uint64) kvmpa((uint64) &buf0);
    80006164:	fa042983          	lw	s3,-96(s0)
    80006168:	00499493          	slli	s1,s3,0x4
    8000616c:	0001fa17          	auipc	s4,0x1f
    80006170:	e94a0a13          	addi	s4,s4,-364 # 80025000 <disk+0x2000>
    80006174:	000a3a83          	ld	s5,0(s4)
    80006178:	9aa6                	add	s5,s5,s1
    8000617a:	f9040513          	addi	a0,s0,-112
    8000617e:	ffffb097          	auipc	ra,0xffffb
    80006182:	f96080e7          	jalr	-106(ra) # 80001114 <kvmpa>
    80006186:	00aab023          	sd	a0,0(s5)
  disk.desc[idx[0]].len = sizeof(buf0);
    8000618a:	000a3783          	ld	a5,0(s4)
    8000618e:	97a6                	add	a5,a5,s1
    80006190:	4741                	li	a4,16
    80006192:	c798                	sw	a4,8(a5)
  disk.desc[idx[0]].flags = VRING_DESC_F_NEXT;
    80006194:	000a3783          	ld	a5,0(s4)
    80006198:	97a6                	add	a5,a5,s1
    8000619a:	4705                	li	a4,1
    8000619c:	00e79623          	sh	a4,12(a5)
  disk.desc[idx[0]].next = idx[1];
    800061a0:	fa442703          	lw	a4,-92(s0)
    800061a4:	000a3783          	ld	a5,0(s4)
    800061a8:	97a6                	add	a5,a5,s1
    800061aa:	00e79723          	sh	a4,14(a5)

  disk.desc[idx[1]].addr = (uint64) b->data;
    800061ae:	0712                	slli	a4,a4,0x4
    800061b0:	000a3783          	ld	a5,0(s4)
    800061b4:	97ba                	add	a5,a5,a4
    800061b6:	05890693          	addi	a3,s2,88
    800061ba:	e394                	sd	a3,0(a5)
  disk.desc[idx[1]].len = BSIZE;
    800061bc:	000a3783          	ld	a5,0(s4)
    800061c0:	97ba                	add	a5,a5,a4
    800061c2:	40000693          	li	a3,1024
    800061c6:	c794                	sw	a3,8(a5)
  if(write)
    800061c8:	100c0863          	beqz	s8,800062d8 <virtio_disk_rw+0x26a>
    disk.desc[idx[1]].flags = 0; // device reads b->data
    800061cc:	000a3783          	ld	a5,0(s4)
    800061d0:	97ba                	add	a5,a5,a4
    800061d2:	00079623          	sh	zero,12(a5)
  else
    disk.desc[idx[1]].flags = VRING_DESC_F_WRITE; // device writes b->data
  disk.desc[idx[1]].flags |= VRING_DESC_F_NEXT;
    800061d6:	0001d517          	auipc	a0,0x1d
    800061da:	e2a50513          	addi	a0,a0,-470 # 80023000 <disk>
    800061de:	0001f797          	auipc	a5,0x1f
    800061e2:	e2278793          	addi	a5,a5,-478 # 80025000 <disk+0x2000>
    800061e6:	6394                	ld	a3,0(a5)
    800061e8:	96ba                	add	a3,a3,a4
    800061ea:	00c6d603          	lhu	a2,12(a3)
    800061ee:	00166613          	ori	a2,a2,1
    800061f2:	00c69623          	sh	a2,12(a3)
  disk.desc[idx[1]].next = idx[2];
    800061f6:	fa842683          	lw	a3,-88(s0)
    800061fa:	6390                	ld	a2,0(a5)
    800061fc:	9732                	add	a4,a4,a2
    800061fe:	00d71723          	sh	a3,14(a4)

  disk.info[idx[0]].status = 0;
    80006202:	20098613          	addi	a2,s3,512
    80006206:	0612                	slli	a2,a2,0x4
    80006208:	962a                	add	a2,a2,a0
    8000620a:	02060823          	sb	zero,48(a2) # 2030 <_entry-0x7fffdfd0>
  disk.desc[idx[2]].addr = (uint64) &disk.info[idx[0]].status;
    8000620e:	00469713          	slli	a4,a3,0x4
    80006212:	6394                	ld	a3,0(a5)
    80006214:	96ba                	add	a3,a3,a4
    80006216:	6589                	lui	a1,0x2
    80006218:	03058593          	addi	a1,a1,48 # 2030 <_entry-0x7fffdfd0>
    8000621c:	94ae                	add	s1,s1,a1
    8000621e:	94aa                	add	s1,s1,a0
    80006220:	e284                	sd	s1,0(a3)
  disk.desc[idx[2]].len = 1;
    80006222:	6394                	ld	a3,0(a5)
    80006224:	96ba                	add	a3,a3,a4
    80006226:	4585                	li	a1,1
    80006228:	c68c                	sw	a1,8(a3)
  disk.desc[idx[2]].flags = VRING_DESC_F_WRITE; // device writes the status
    8000622a:	6394                	ld	a3,0(a5)
    8000622c:	96ba                	add	a3,a3,a4
    8000622e:	4509                	li	a0,2
    80006230:	00a69623          	sh	a0,12(a3)
  disk.desc[idx[2]].next = 0;
    80006234:	6394                	ld	a3,0(a5)
    80006236:	9736                	add	a4,a4,a3
    80006238:	00071723          	sh	zero,14(a4)

  // record struct buf for virtio_disk_intr().
  b->disk = 1;
    8000623c:	00b92223          	sw	a1,4(s2)
  disk.info[idx[0]].b = b;
    80006240:	03263423          	sd	s2,40(a2)

  // avail[0] is flags
  // avail[1] tells the device how far to look in avail[2...].
  // avail[2...] are desc[] indices the device should process.
  // we only tell device the first index in our chain of descriptors.
  disk.avail[2 + (disk.avail[1] % NUM)] = idx[0];
    80006244:	6794                	ld	a3,8(a5)
    80006246:	0026d703          	lhu	a4,2(a3)
    8000624a:	8b1d                	andi	a4,a4,7
    8000624c:	2709                	addiw	a4,a4,2
    8000624e:	0706                	slli	a4,a4,0x1
    80006250:	9736                	add	a4,a4,a3
    80006252:	01371023          	sh	s3,0(a4)
  __sync_synchronize();
    80006256:	0ff0000f          	fence
  disk.avail[1] = disk.avail[1] + 1;
    8000625a:	6798                	ld	a4,8(a5)
    8000625c:	00275783          	lhu	a5,2(a4)
    80006260:	2785                	addiw	a5,a5,1
    80006262:	00f71123          	sh	a5,2(a4)

  *R(VIRTIO_MMIO_QUEUE_NOTIFY) = 0; // value is queue number
    80006266:	100017b7          	lui	a5,0x10001
    8000626a:	0407a823          	sw	zero,80(a5) # 10001050 <_entry-0x6fffefb0>

  // Wait for virtio_disk_intr() to say request has finished.
  while(b->disk == 1) {
    8000626e:	00492703          	lw	a4,4(s2)
    80006272:	4785                	li	a5,1
    80006274:	02f71163          	bne	a4,a5,80006296 <virtio_disk_rw+0x228>
    sleep(b, &disk.vdisk_lock);
    80006278:	0001f997          	auipc	s3,0x1f
    8000627c:	e3098993          	addi	s3,s3,-464 # 800250a8 <disk+0x20a8>
  while(b->disk == 1) {
    80006280:	4485                	li	s1,1
    sleep(b, &disk.vdisk_lock);
    80006282:	85ce                	mv	a1,s3
    80006284:	854a                	mv	a0,s2
    80006286:	ffffc097          	auipc	ra,0xffffc
    8000628a:	02c080e7          	jalr	44(ra) # 800022b2 <sleep>
  while(b->disk == 1) {
    8000628e:	00492783          	lw	a5,4(s2)
    80006292:	fe9788e3          	beq	a5,s1,80006282 <virtio_disk_rw+0x214>
  }

  disk.info[idx[0]].b = 0;
    80006296:	fa042483          	lw	s1,-96(s0)
    8000629a:	20048793          	addi	a5,s1,512 # 10001200 <_entry-0x6fffee00>
    8000629e:	00479713          	slli	a4,a5,0x4
    800062a2:	0001d797          	auipc	a5,0x1d
    800062a6:	d5e78793          	addi	a5,a5,-674 # 80023000 <disk>
    800062aa:	97ba                	add	a5,a5,a4
    800062ac:	0207b423          	sd	zero,40(a5)
    if(disk.desc[i].flags & VRING_DESC_F_NEXT)
    800062b0:	0001f917          	auipc	s2,0x1f
    800062b4:	d5090913          	addi	s2,s2,-688 # 80025000 <disk+0x2000>
    free_desc(i);
    800062b8:	8526                	mv	a0,s1
    800062ba:	00000097          	auipc	ra,0x0
    800062be:	bec080e7          	jalr	-1044(ra) # 80005ea6 <free_desc>
    if(disk.desc[i].flags & VRING_DESC_F_NEXT)
    800062c2:	0492                	slli	s1,s1,0x4
    800062c4:	00093783          	ld	a5,0(s2)
    800062c8:	94be                	add	s1,s1,a5
    800062ca:	00c4d783          	lhu	a5,12(s1)
    800062ce:	8b85                	andi	a5,a5,1
    800062d0:	cf91                	beqz	a5,800062ec <virtio_disk_rw+0x27e>
      i = disk.desc[i].next;
    800062d2:	00e4d483          	lhu	s1,14(s1)
  while(1){
    800062d6:	b7cd                	j	800062b8 <virtio_disk_rw+0x24a>
    disk.desc[idx[1]].flags = VRING_DESC_F_WRITE; // device writes b->data
    800062d8:	0001f797          	auipc	a5,0x1f
    800062dc:	d2878793          	addi	a5,a5,-728 # 80025000 <disk+0x2000>
    800062e0:	639c                	ld	a5,0(a5)
    800062e2:	97ba                	add	a5,a5,a4
    800062e4:	4689                	li	a3,2
    800062e6:	00d79623          	sh	a3,12(a5)
    800062ea:	b5f5                	j	800061d6 <virtio_disk_rw+0x168>
  free_chain(idx[0]);

  release(&disk.vdisk_lock);
    800062ec:	0001f517          	auipc	a0,0x1f
    800062f0:	dbc50513          	addi	a0,a0,-580 # 800250a8 <disk+0x20a8>
    800062f4:	ffffb097          	auipc	ra,0xffffb
    800062f8:	a22080e7          	jalr	-1502(ra) # 80000d16 <release>
}
    800062fc:	70a6                	ld	ra,104(sp)
    800062fe:	7406                	ld	s0,96(sp)
    80006300:	64e6                	ld	s1,88(sp)
    80006302:	6946                	ld	s2,80(sp)
    80006304:	69a6                	ld	s3,72(sp)
    80006306:	6a06                	ld	s4,64(sp)
    80006308:	7ae2                	ld	s5,56(sp)
    8000630a:	7b42                	ld	s6,48(sp)
    8000630c:	7ba2                	ld	s7,40(sp)
    8000630e:	7c02                	ld	s8,32(sp)
    80006310:	6165                	addi	sp,sp,112
    80006312:	8082                	ret
  if(write)
    80006314:	e40c11e3          	bnez	s8,80006156 <virtio_disk_rw+0xe8>
    buf0.type = VIRTIO_BLK_T_IN; // read the disk
    80006318:	f8042823          	sw	zero,-112(s0)
    8000631c:	b581                	j	8000615c <virtio_disk_rw+0xee>
      disk.free[i] = 0;
    8000631e:	00098c23          	sb	zero,24(s3)
    idx[i] = alloc_desc();
    80006322:	00072023          	sw	zero,0(a4)
    if(idx[i] < 0){
    80006326:	b365                	j	800060ce <virtio_disk_rw+0x60>

0000000080006328 <virtio_disk_intr>:

void
virtio_disk_intr()
{
    80006328:	1101                	addi	sp,sp,-32
    8000632a:	ec06                	sd	ra,24(sp)
    8000632c:	e822                	sd	s0,16(sp)
    8000632e:	e426                	sd	s1,8(sp)
    80006330:	e04a                	sd	s2,0(sp)
    80006332:	1000                	addi	s0,sp,32
  acquire(&disk.vdisk_lock);
    80006334:	0001f517          	auipc	a0,0x1f
    80006338:	d7450513          	addi	a0,a0,-652 # 800250a8 <disk+0x20a8>
    8000633c:	ffffb097          	auipc	ra,0xffffb
    80006340:	926080e7          	jalr	-1754(ra) # 80000c62 <acquire>

  while((disk.used_idx % NUM) != (disk.used->id % NUM)){
    80006344:	0001f797          	auipc	a5,0x1f
    80006348:	cbc78793          	addi	a5,a5,-836 # 80025000 <disk+0x2000>
    8000634c:	0207d683          	lhu	a3,32(a5)
    80006350:	6b98                	ld	a4,16(a5)
    80006352:	00275783          	lhu	a5,2(a4)
    80006356:	8fb5                	xor	a5,a5,a3
    80006358:	8b9d                	andi	a5,a5,7
    8000635a:	c7c9                	beqz	a5,800063e4 <virtio_disk_intr+0xbc>
    int id = disk.used->elems[disk.used_idx].id;
    8000635c:	068e                	slli	a3,a3,0x3
    8000635e:	9736                	add	a4,a4,a3
    80006360:	435c                	lw	a5,4(a4)

    if(disk.info[id].status != 0)
    80006362:	20078713          	addi	a4,a5,512
    80006366:	00471693          	slli	a3,a4,0x4
    8000636a:	0001d717          	auipc	a4,0x1d
    8000636e:	c9670713          	addi	a4,a4,-874 # 80023000 <disk>
    80006372:	9736                	add	a4,a4,a3
    80006374:	03074703          	lbu	a4,48(a4)
    80006378:	ef31                	bnez	a4,800063d4 <virtio_disk_intr+0xac>
      panic("virtio_disk_intr status");
    
    disk.info[id].b->disk = 0;   // disk is done with buf
    8000637a:	0001d917          	auipc	s2,0x1d
    8000637e:	c8690913          	addi	s2,s2,-890 # 80023000 <disk>
    wakeup(disk.info[id].b);

    disk.used_idx = (disk.used_idx + 1) % NUM;
    80006382:	0001f497          	auipc	s1,0x1f
    80006386:	c7e48493          	addi	s1,s1,-898 # 80025000 <disk+0x2000>
    disk.info[id].b->disk = 0;   // disk is done with buf
    8000638a:	20078793          	addi	a5,a5,512
    8000638e:	0792                	slli	a5,a5,0x4
    80006390:	97ca                	add	a5,a5,s2
    80006392:	7798                	ld	a4,40(a5)
    80006394:	00072223          	sw	zero,4(a4)
    wakeup(disk.info[id].b);
    80006398:	7788                	ld	a0,40(a5)
    8000639a:	ffffc097          	auipc	ra,0xffffc
    8000639e:	09e080e7          	jalr	158(ra) # 80002438 <wakeup>
    disk.used_idx = (disk.used_idx + 1) % NUM;
    800063a2:	0204d783          	lhu	a5,32(s1)
    800063a6:	2785                	addiw	a5,a5,1
    800063a8:	8b9d                	andi	a5,a5,7
    800063aa:	03079613          	slli	a2,a5,0x30
    800063ae:	9241                	srli	a2,a2,0x30
    800063b0:	02c49023          	sh	a2,32(s1)
  while((disk.used_idx % NUM) != (disk.used->id % NUM)){
    800063b4:	6898                	ld	a4,16(s1)
    800063b6:	00275683          	lhu	a3,2(a4)
    800063ba:	8a9d                	andi	a3,a3,7
    800063bc:	02c68463          	beq	a3,a2,800063e4 <virtio_disk_intr+0xbc>
    int id = disk.used->elems[disk.used_idx].id;
    800063c0:	078e                	slli	a5,a5,0x3
    800063c2:	97ba                	add	a5,a5,a4
    800063c4:	43dc                	lw	a5,4(a5)
    if(disk.info[id].status != 0)
    800063c6:	20078713          	addi	a4,a5,512
    800063ca:	0712                	slli	a4,a4,0x4
    800063cc:	974a                	add	a4,a4,s2
    800063ce:	03074703          	lbu	a4,48(a4)
    800063d2:	df45                	beqz	a4,8000638a <virtio_disk_intr+0x62>
      panic("virtio_disk_intr status");
    800063d4:	00002517          	auipc	a0,0x2
    800063d8:	3bc50513          	addi	a0,a0,956 # 80008790 <syscalls+0x3f8>
    800063dc:	ffffa097          	auipc	ra,0xffffa
    800063e0:	198080e7          	jalr	408(ra) # 80000574 <panic>
  }
  *R(VIRTIO_MMIO_INTERRUPT_ACK) = *R(VIRTIO_MMIO_INTERRUPT_STATUS) & 0x3;
    800063e4:	10001737          	lui	a4,0x10001
    800063e8:	533c                	lw	a5,96(a4)
    800063ea:	8b8d                	andi	a5,a5,3
    800063ec:	d37c                	sw	a5,100(a4)

  release(&disk.vdisk_lock);
    800063ee:	0001f517          	auipc	a0,0x1f
    800063f2:	cba50513          	addi	a0,a0,-838 # 800250a8 <disk+0x20a8>
    800063f6:	ffffb097          	auipc	ra,0xffffb
    800063fa:	920080e7          	jalr	-1760(ra) # 80000d16 <release>
}
    800063fe:	60e2                	ld	ra,24(sp)
    80006400:	6442                	ld	s0,16(sp)
    80006402:	64a2                	ld	s1,8(sp)
    80006404:	6902                	ld	s2,0(sp)
    80006406:	6105                	addi	sp,sp,32
    80006408:	8082                	ret
	...

0000000080007000 <_trampoline>:
    80007000:	14051573          	csrrw	a0,sscratch,a0
    80007004:	02153423          	sd	ra,40(a0)
    80007008:	02253823          	sd	sp,48(a0)
    8000700c:	02353c23          	sd	gp,56(a0)
    80007010:	04453023          	sd	tp,64(a0)
    80007014:	04553423          	sd	t0,72(a0)
    80007018:	04653823          	sd	t1,80(a0)
    8000701c:	04753c23          	sd	t2,88(a0)
    80007020:	f120                	sd	s0,96(a0)
    80007022:	f524                	sd	s1,104(a0)
    80007024:	fd2c                	sd	a1,120(a0)
    80007026:	e150                	sd	a2,128(a0)
    80007028:	e554                	sd	a3,136(a0)
    8000702a:	e958                	sd	a4,144(a0)
    8000702c:	ed5c                	sd	a5,152(a0)
    8000702e:	0b053023          	sd	a6,160(a0)
    80007032:	0b153423          	sd	a7,168(a0)
    80007036:	0b253823          	sd	s2,176(a0)
    8000703a:	0b353c23          	sd	s3,184(a0)
    8000703e:	0d453023          	sd	s4,192(a0)
    80007042:	0d553423          	sd	s5,200(a0)
    80007046:	0d653823          	sd	s6,208(a0)
    8000704a:	0d753c23          	sd	s7,216(a0)
    8000704e:	0f853023          	sd	s8,224(a0)
    80007052:	0f953423          	sd	s9,232(a0)
    80007056:	0fa53823          	sd	s10,240(a0)
    8000705a:	0fb53c23          	sd	s11,248(a0)
    8000705e:	11c53023          	sd	t3,256(a0)
    80007062:	11d53423          	sd	t4,264(a0)
    80007066:	11e53823          	sd	t5,272(a0)
    8000706a:	11f53c23          	sd	t6,280(a0)
    8000706e:	140022f3          	csrr	t0,sscratch
    80007072:	06553823          	sd	t0,112(a0)
    80007076:	00853103          	ld	sp,8(a0)
    8000707a:	02053203          	ld	tp,32(a0)
    8000707e:	01053283          	ld	t0,16(a0)
    80007082:	00053303          	ld	t1,0(a0)
    80007086:	18031073          	csrw	satp,t1
    8000708a:	12000073          	sfence.vma
    8000708e:	8282                	jr	t0

0000000080007090 <userret>:
    80007090:	18059073          	csrw	satp,a1
    80007094:	12000073          	sfence.vma
    80007098:	07053283          	ld	t0,112(a0)
    8000709c:	14029073          	csrw	sscratch,t0
    800070a0:	02853083          	ld	ra,40(a0)
    800070a4:	03053103          	ld	sp,48(a0)
    800070a8:	03853183          	ld	gp,56(a0)
    800070ac:	04053203          	ld	tp,64(a0)
    800070b0:	04853283          	ld	t0,72(a0)
    800070b4:	05053303          	ld	t1,80(a0)
    800070b8:	05853383          	ld	t2,88(a0)
    800070bc:	7120                	ld	s0,96(a0)
    800070be:	7524                	ld	s1,104(a0)
    800070c0:	7d2c                	ld	a1,120(a0)
    800070c2:	6150                	ld	a2,128(a0)
    800070c4:	6554                	ld	a3,136(a0)
    800070c6:	6958                	ld	a4,144(a0)
    800070c8:	6d5c                	ld	a5,152(a0)
    800070ca:	0a053803          	ld	a6,160(a0)
    800070ce:	0a853883          	ld	a7,168(a0)
    800070d2:	0b053903          	ld	s2,176(a0)
    800070d6:	0b853983          	ld	s3,184(a0)
    800070da:	0c053a03          	ld	s4,192(a0)
    800070de:	0c853a83          	ld	s5,200(a0)
    800070e2:	0d053b03          	ld	s6,208(a0)
    800070e6:	0d853b83          	ld	s7,216(a0)
    800070ea:	0e053c03          	ld	s8,224(a0)
    800070ee:	0e853c83          	ld	s9,232(a0)
    800070f2:	0f053d03          	ld	s10,240(a0)
    800070f6:	0f853d83          	ld	s11,248(a0)
    800070fa:	10053e03          	ld	t3,256(a0)
    800070fe:	10853e83          	ld	t4,264(a0)
    80007102:	11053f03          	ld	t5,272(a0)
    80007106:	11853f83          	ld	t6,280(a0)
    8000710a:	14051573          	csrrw	a0,sscratch,a0
    8000710e:	10200073          	sret
	...
